some help on Editable Detail views

Discussion in 'iOS Programming' started by kingthong, Mar 18, 2011.

  1. kingthong macrumors member

    Joined:
    Sep 20, 2010
    Location:
    Somewhere but not here.
    #1
    Hey,

    I've not been able to find any good info on editable detail views. can someone help me out with either some source code/blog or anything that might be of use to me.

    what i'm trying to achieve is similar to this

    http://i.imgur.com/wLW0T.jpg
    (more specifically the picture on the right)

    any help will be appreciated.
    Thanks!
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
  3. kingthong thread starter macrumors member

    Joined:
    Sep 20, 2010
    Location:
    Somewhere but not here.
    #3
    Thanks. The buttons on the topbar are left and right bar button item.

    I shoulda been a little more clear in the question but i was wondering how you would do the "repeat", "sound" and "snooze" part of the view that i've linked.
     
  4. kingthong thread starter macrumors member

    Joined:
    Sep 20, 2010
    Location:
    Somewhere but not here.
    #4
    Actually this is a grouped table view.
    My only questions is how to edit it and display the result of the editing in the cell itself?
     
  5. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #5
    You have a data model linked to the view via a controller layer. Just as normal.
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Please elaborate on what you mean by "how to edit it". Because for the alarm setting example you're using, you'll see that 3 of the 4 rows actually push a new view controller onto the nav stack (2 of which are also grouped tables).
     
  7. kingthong thread starter macrumors member

    Joined:
    Sep 20, 2010
    Location:
    Somewhere but not here.
    #7
    Hi Dejo.

    What i exactly want to do is have a view like the alarm settings page.

    When i click on the 'Repeat' cell, a action sheet should pop up with few options
    and which ever option i click should be displayed in the same table cell. (like how the word 'Never' appears in the example picture i've linked).

    I've basically not figured out the logic on how to do this.
     
  8. kingthong thread starter macrumors member

    Joined:
    Sep 20, 2010
    Location:
    Somewhere but not here.
  9. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #9
    If that's what u want, shouldn't be so hard. there is a Special build in function for this, well, not function, but new Header files for this.
    Go new file, Objective-C class, then select, instead of NSObject, TableViewCell, and tadaa :p
    Because, what u sended, is the standard. u can customize it yourself by using NIB/Xib's.

    If u want to use the standard build in go to your delegate methods of your UITableView like this

    Code:
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    	
    	static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:[B]UITableViewCellStyleValue2[/B] reuseIdentifier:CellIdentifier] autorelease];
    		cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }
    	
    	switch (indexPath.row) {
            case 0: 
    			cell.textLabel.text = @"Title";
    cell.detailTextLabel.text = @"Test";
    			break;
            case 1: 
    			cell.textLabel.text = @"Author";
    cell.detailTextLabel.text = @"Test2";
    			break;
            case 2:
    			cell.textLabel.text = @"Copyright";
    cell.detailTextLabel.text = @"Test3";
    			break;
        }
        return cell;
    }
    Something like that
    The most important is the thing i put in bold. u can edit it to your likings.
    have fun
     

Share This Page