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 01-03-2010, 08:12 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 41
alexgiul is on a distinguished road
Default Add fixed row in a table view

Hi all!

I would know if it's possible and how add a fixed row in a table as last row.

I try to explain better: I have an array, dynically loaded, and I want to show the "+" sign when I enable the table editing i a row named "Add New item".

I think I should manage into method "cellForRowAtIndexPath" but I don't what I should do

Thanks a lot
alexgiul is offline   Reply With Quote
Old 01-03-2010, 10:40 AM   #2 (permalink)
Remya
 
Join Date: Dec 2009
Location: India
Posts: 65
rainmobile is on a distinguished road
Default

Quote:
Originally Posted by alexgiul View Post
Hi all!

I would know if it's possible and how add a fixed row in a table as last row.

I try to explain better: I have an array, dynically loaded, and I want to show the "+" sign when I enable the table editing i a row named "Add New item".

I think I should manage into method "cellForRowAtIndexPath" but I don't what I should do

Thanks a lot



Hi

Try to append the array with last element name "Add new item" ,so u can easily display it.


Best Regards.
rainmobile is offline   Reply With Quote
Old 01-03-2010, 11:12 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Poznan, Poland
Posts: 32
wojtkow is on a distinguished road
Default

Quote:
Originally Posted by alexgiul View Post
I think I should manage into method "cellForRowAtIndexPath" but I don't what I should do
1. In -
Code:
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
method add one to current value in ex. if you have
return [dataArray count] change it to return [dataArray count]+1;

2. In -
Code:
 (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
when indexPath.row < [dataArray count] put your normal code and when

indexPath.row = [dataArray count] add code like here:
Code:
cell.text = "Add New item";
3. In -
Code:
(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
add code like here:
Code:
        if (indexPath.row == [dataArray count]) {
            style = UITableViewCellEditingStyleInsert;
        }
__________________
My apps:
Paths
Project Planner
Project Planner HD
wojtkow is offline   Reply With Quote
Old 01-03-2010, 02:58 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 41
alexgiul is on a distinguished road
Default

Quote:
Originally Posted by wojtkow View Post
1. In -
Code:
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
method add one to current value in ex. if you have
return [dataArray count] change it to return [dataArray count]+1;

2. In -
Code:
 (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
when indexPath.row < [dataArray count] put your normal code and when

indexPath.row = [dataArray count] add code like here:
Code:
cell.text = "Add New item";
3. In -
Code:
(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
add code like here:
Code:
        if (indexPath.row == [dataArray count]) {
            style = UITableViewCellEditingStyleInsert;
        }
Thanks a lot,

with your tips I get it working as expected, but I have a question:
in the way you tell m, I have always "Add New Item" on the list, so I decided to put a code like the following :
Code:
if(self.editing) cell.text = "Add New item";
in this way I thought to show the msg "Add new Item" with green plus sign only when I'm in edinting mode, but in the simulator the msg disappear.

Where am I wrong?
alexgiul is offline   Reply With Quote
Old 01-03-2010, 03:25 PM   #5 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Poznan, Poland
Posts: 32
wojtkow is on a distinguished road
Default

Quote:
Originally Posted by alexgiul View Post
in this way I thought to show the msg "Add new Item" with green plus sign only when I'm in edinting mode, but in the simulator the msg disappear.
In numberOfRowsInSection put code like here

Code:
            
NSInteger rows = [dataArray count];
if (self.editing) {
    rows++;
}
return rows
and don't manipulate with self.editing in cellForRowAtIndexPath
look into iPhoneCoreDataRecipes in AppleDocs - this is good example.
__________________
My apps:
Paths
Project Planner
Project Planner HD
wojtkow is offline   Reply With Quote
Old 01-03-2010, 03:33 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 41
alexgiul is on a distinguished road
Default

Quote:
Originally Posted by wojtkow View Post
In numberOfRowsInSection put code like here

Code:
            
NSInteger rows = [dataArray count];
if (self.editing) {
    rows++;
}
return rows
and don't manipulate with self.editing in cellForRowAtIndexPath
look into iPhoneCoreDataRecipes in AppleDocs - this is good example.
it doesn't work, I follow in debug and the application calls "numberOfRowsInSection" only at the starting point and not when I click on edit button..maybe should I refresh the content of table?
alexgiul is offline   Reply With Quote
Reply

Bookmarks

Tags
row fixed, table

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: 342
16 members and 326 guests
akacaj, alexP, ClerurcifeDer, Domele, Duncan C, givensur, GraffitiCircus, guusleijsten, JmayLive, michelle, NetGuru, NSString, Paul Slocum, Punkjumper, Sloshmonster, soohyun
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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