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 10-13-2009, 08:13 AM   #1 (permalink)
lex
Registered Member
 
Join Date: Oct 2009
Location: Switzerland
Posts: 7
lex is on a distinguished road
Unhappy Another UITableViewController problem

Hay at all readers out there,
At first let me please say that im not to stupid or to lazy to use google or search function in here.

I have a big problem.

I've build in my app delegate a UINavigation controller with my MainView (UIViewController) as a RootController.

Code:
mainView = [[[MainView alloc] initWithNibName:nil bundle:nil] autorelease];
	navigationController = [[UINavigationController alloc] initWithRootViewController:mainView];
	//window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
	[window addSubview:[navigationController view]];
    // Override point for customization after application launch
    [window makeKeyAndVisible];

Tis works without problems, I push and pop some UIViews there for Navigation purposes without dislaying the Navbar, this also works.

I push on the stack a UITableviewcontroller with an object reference to an object which my appdelegate constructs. my tableview is also populated with the correct dataparts. and i can edit and delete my entries and also I have a working detailview.

All works, EXCEPT TWO THINGS,

if i change in the Edit view (clic in my tableview on an entry --> Detail view with all data ->edit -> datapart -> Editview) and save this and get poped back to detail view, NOTHING changed in the view, no deselect of the cell and no refresh, if I enter again the edit view the data are correct.
if i pop back to the table view the data also are not refreshed, and if i push again the detail view all data correct. if i scroll up and downwards, the cells wich dissapear are refreshed. the same with the Add Item menu.

I inserted the tableView reloadData and other tries but nothing worked for me.

I generate all programmatically because i dislike the IB.

I think i have troubles with the datadelegate and the tableviewdelegate.

I found nothing about that how i had to connect these correct to my files.
The example i looked in was partly build with IB and I can't figure out how this works with the delegate things.

I hope my question is not to stupid.
and thanks that tis forum exist it helped me till now very very much.
lex is offline   Reply With Quote
Old 10-13-2009, 11:50 AM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Quote:
Originally Posted by lex View Post
I inserted the tableView reloadData...
Where?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 10-13-2009, 12:51 PM   #3 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
jsd is on a distinguished road
Default

Quote:
Originally Posted by lex View Post
I generate all programmatically because i dislike the IB.
Sorry, I don't have the answer to your question, but I had to respond to the line you said above.

You should read this and then start learning IB.

iPhone Development: Don't Fear the Interface Builder
jsd is offline   Reply With Quote
Old 10-14-2009, 01:55 AM   #4 (permalink)
lex
Registered Member
 
Join Date: Oct 2009
Location: Switzerland
Posts: 7
lex is on a distinguished road
Default

I inserted the reloadData once in viewwillappear, here some code


Code:
- (void)viewDidLoad {
	NSLog(@"viewdidload");
    self.navigationItem.rightBarButtonItem = self.editButtonItem;
	[self.tableView reloadData];
}

- (void)viewWillAppear:(BOOL)animated {
	NSLog(@"viewwillappear");
    
	//no work
	[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:NO];

	// also no work
	[[self tableView] reloadData];
	//the same
	[self.tableView reloadData];
}

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
	NSLog(@"setediting");
    [super setEditing:editing animated:animated];
    [self.navigationItem setHidesBackButton:editing animated:animated];
    //also no work
    [tableView reloadData];
}
All works except the refresh and the deselecting.

in attachement is the example i wanted to rebuild without the IB because then i know what the programm does, i thought, IB is for me too fixed. its like if you somebody from the c world say he should use visual basic. im not angry or something i only try my way.

can you tell me how i had to set my delegates ???


following the header files from my own build.
compilation without error.

My DetailView

Code:
#import <UIKit/UIKit.h>


@class Ship, EditingViewController;

@interface DetailView : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
    Ship *ship;
    IBOutlet UITableView *tableView;
    NSDateFormatter *dateFormatter;
    NSIndexPath *selectedIndexPath;
}

@property (nonatomic, retain) NSDateFormatter *dateFormatter;
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSIndexPath *selectedIndexPath;
// Expose the book property to other objects (the MasterViewController).
@property (nonatomic, retain) Ship *ship;

@end

My EditingView

Code:
@interface EditingViewController : UIViewController {
    NSString *textValue;
    id editedObject;
    NSString *editedFieldKey;
    IBOutlet UITextField *textField;
    BOOL dateEditing;
    NSDate *dateValue;
    IBOutlet UIDatePicker *datePicker;
    NSDateFormatter *dateFormatter;
}

@property (nonatomic, retain) id editedObject;
@property (nonatomic, retain) NSString *textValue;
@property (nonatomic, retain) NSDate *dateValue;
@property (nonatomic, retain) NSString *editedFieldKey;
@property (nonatomic, assign) BOOL dateEditing;
@property (nonatomic, readonly) UITextField *textField;
@property (nonatomic, retain) NSDateFormatter *dateFormatter;

- (IBAction)cancel:(id)sender;
- (IBAction)save:(id)sender;
- (IBAction)dateChanged:(id)sender;

@end

my AddView
Code:
#import <UIKit/UIKit.h>


#import "DetailView.h"

@interface AddViewController : DetailView

- (IBAction)cancel:(id)sender;
- (IBAction)save:(id)sender;

@end

and my ShipController

Code:
#import <UIKit/UIKit.h>

@class DetailView, AddViewController, EditingViewController, Ship;

@interface ShipViewController : UITableViewController <UITableViewDelegate,UITableViewDataSource>{
	
	IBOutlet UITableView *tableView;
    UINavigationController *addNavigationController;
    DetailView *detailView;
    AddViewController *addViewController;

}

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) UINavigationController *addNavigationController;
@property (nonatomic, retain) DetailView *detailView;
@property (nonatomic, retain) AddViewController *addViewController;

+ (EditingViewController *)editingViewController;

- (IBAction)addShip:(id)sender;
- (IBAction)backIt;

@end

This is how i push the shipcontroller on the stack.

Code:
....

- (ShipViewController *)shipViewController {
	NSLog(@"ShipView Invoked");
	
    // Instantiate the detail view controller if necessary.
    if (shipViewController == nil) {
        shipViewController = [[ShipViewController alloc] initWithStyle:UITableViewStyleGrouped];
    }else{
		
		shipViewController = nil;
		shipViewController = [[ShipViewController alloc] initWithStyle:UITableViewStyleGrouped];
		NSLog(@"pclistview no New Detail anzeige Invoked");
		
		
	}
    return shipViewController;
}


//-----------


-(IBAction)shipview{
	
	ShipViewController *swc = self.shipViewController;
	[self.navigationController pushViewController:swc animated:YES];
	[swc release];
	
	
}
and this is the button which exists in the init
Code:
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button2.frame = CGRectMake(100, 170, 120, 30);
[button2 setTitle:@"Schiffe" forState:UIControlStateNormal];
[button2 addTarget:self action:@selector(shipview) 
		  forControlEvents:UIControlEventTouchUpInside];
		[self.view addSubview:button2];
please have a look at it
Attached Files
File Type: zip SQLiteBooks.zip (84.5 KB, 34 views)
lex is offline   Reply With Quote
Old 10-14-2009, 10:49 AM   #5 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
jsd is on a distinguished road
Default

Have you checked to see if self.tableView exists during the viewWillAppear call? I bet it doesn't. NSLog it and see.
jsd is offline   Reply With Quote
Old 10-14-2009, 10:58 AM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Code:
#import <UIKit/UIKit.h>


@class Ship, EditingViewController;

@interface DetailView : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
    Ship *ship;
    IBOutlet UITableView *tableView;
    NSDateFormatter *dateFormatter;
    NSIndexPath *selectedIndexPath;
}

@property (nonatomic, retain) NSDateFormatter *dateFormatter;
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSIndexPath *selectedIndexPath;
// Expose the book property to other objects (the MasterViewController).
@property (nonatomic, retain) Ship *ship;

@end
Items in red are not necessary for a UITableViewController, and possibly are contributing to your problem if not done correctly. See the table view link in my signature for more information.

Code:
#import <UIKit/UIKit.h>

@class DetailView, AddViewController, EditingViewController, Ship;

@interface ShipViewController : UITableViewController <UITableViewDelegate,UITableViewDataSource>{
	
	IBOutlet UITableView *tableView;
    UINavigationController *addNavigationController;
    DetailView *detailView;
    AddViewController *addViewController;

}

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) UINavigationController *addNavigationController;
@property (nonatomic, retain) DetailView *detailView;
@property (nonatomic, retain) AddViewController *addViewController;

+ (EditingViewController *)editingViewController;

- (IBAction)addShip:(id)sender;
- (IBAction)backIt;

@end
Why do you have a navigation controller inside of a view controller? I'm going to guess this is your problem.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 10-15-2009, 02:14 AM   #7 (permalink)
lex
Registered Member
 
Join Date: Oct 2009
Location: Switzerland
Posts: 7
lex is on a distinguished road
Default

@briterideas
Ok that helped a bit, i didnt know that it works without, but now there on the addView ( this loads the detail view ) there on each cell the erase signs on the left. ive added you to aim, if you are in the mood for reading my silly postings via aim i would be pleased. my is lexarion (aT) mac.com


Thanks for helping me till now
lex is offline   Reply With Quote
Reply

Bookmarks

Tags
cocoa, cocoa-touch, iphone, uitableview, uiview

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: 339
9 members and 330 guests
givensur, glenn_sayers, guusleijsten, ipodphone, mediaspree, mtl_tech_guy, Punkjumper, whitey99, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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