Jack Nutkins
Jack Nutkins

Reputation: 1555

Objective - C Custom Table View Problems

I have this code:

 - (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"ViewDidLoad");

    username = @"itemstiubhart1";
    titleEle = @"titlestiubhart1";
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"ViewWillAppear");
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    if ([stories count] == 0) {
        NSString * path = @"http://myurl.com/events.php";
        [self parseXMLFileAtURL:path];
    }
    NSLog(@"viewDidAppear");
}

- (void)viewWillDisappear:(BOOL)animated {
}

- (void)viewDidDisappear:(BOOL)animated {
}

You may need more of my code than this, however I'm sure I'm missing something fairly fundamental. Basically my problem is this, the viewDidLoad method executes fine, however the next method that should run (viewWillAppear) simply doesn't run at all...And a blank table view appears. Am I missing something fundamental? Or is my problem likely a bit more complex? Just seems a bit strange. I have the same code in another project, but that project uses a navigation controller and this one uses a view controller, I think it has something to do with that as the other project works fine.

Thanks,

Jack

Upvotes: 2

Views: 312

Answers (2)

Jyoti Kumari
Jyoti Kumari

Reputation: 45

You have to reload table again when parsing is complete. Table view may coming blank because of empty data values

Upvotes: 0

sergio
sergio

Reputation: 69027

I guess that you are adding the view manually as a subview through [view addSubview:subview].

In this case, you have to call -viewWillAppear: yourself.

Check also this question and Apple Docs (a custom view controller has to implement viewWillAppear).

Upvotes: 2

Related Questions