Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-05-2011, 02:57 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 2
phackdat is on a distinguished road
Red face how to add/insert row from string typed from users from custom alertview

In the tableview the user can tap the upper right button (navigation bar rightside) and it will pop up the custom alert view and ask user to type in the edittext box with two button cancel and save. As you can see in the code below. When i click on save it will add a row and display 'label' to confirm that it is working and now i want to be able to display whatever the user typed in the box. I have read all the tableview apple developer site and search around and they all don't do the way I want.

Code:
- (void) CustomAlertView:(CustomAlertView *)alert wasDismissedWithValue:(NSString *)value
{
    [authorList addObject:@"label"];
    [tblSimpleTable reloadData];
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        // Delete the row from the data source.
        [authorList removeObjectAtIndex:indexPath.row];
        [tblSimpleTable reloadData];
    }
    else if (editingStyle == UITableViewCellEditingStyleInsert)
    {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
        [authorList insertObject:@"label" atIndex:[authorList count]];
        [tblSimpleTable reloadData];
    }   
}
UPDATE***

Code:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if([title isEqualToString:@"Save"])
    {
        NSString *any = [NSString stringWithFormat:@"'%@'"];
        [authorList addObject:any];
        [tblSimpleTable reloadData];
    }
}
insert row code

Code:
else if (editingStyle == UITableViewCellEditingStyleInsert)
    {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
       NSString *any = [NSString stringWithFormat:@"'%@'"];
        [authorList insertObject:any atIndex:[authorList count]];
        //[authorList addObject:any];
        [tblSimpleTable reloadData];

    }   
}

Last edited by phackdat; 11-05-2011 at 05:55 PM. Reason: Updates*
phackdat is offline   Reply With Quote
Reply

Bookmarks

Tags
alertview, insert, insert row, row, tableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 413
17 members and 396 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, dre, FrankWeller, gwelmarten, ipodphone, jeroenkeij, jleannex55, matador1978, n00b, pbart, reficul, Retouchable, Sami Gh, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0