UITableView is being reset when I use Custom Class

user866364

I have a UITableView with 2 text field and a button. If I run the simulator without use custom class, I can see the text fields and button:

correct view without custom class

But when i use a custom class, my UITable view only display a lot of lines without content:

empty lines with custom class

Interface Builder

Here is how I've created my properties:

LoginSceneController.h

#import <UIKit/UIKit.h>

@interface LoginSceneController : UITableViewController

@property (nonatomic, strong) IBOutlet UITextField *email;

@property (nonatomic, strong) IBOutlet UITextField *password;

- (IBAction)doLogin;

@end

LoginSceneController.m

#import "LoginSceneController.h"

@interface LoginSceneController ()

@end

@implementation LoginSceneController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)doLogin {

    NSURL *url = [NSURL URLWithString:@"http://rest-service.guides.spring.io/greeting"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [NSURLConnection sendAsynchronousRequest:request
                                       queue:[NSOperationQueue mainQueue]
                           completionHandler:^(NSURLResponse *response,
                                               NSData *data, NSError *connectionError)
     {
         if (data.length > 0 && connectionError == nil)
         {
             NSDictionary *greeting = [NSJSONSerialization JSONObjectWithData:data
                                                                      options:0
                                                                        error:NULL];
             self.email.text = [[greeting objectForKey:@"id"] stringValue];
             self.password.text = [greeting objectForKey:@"content"];
         }
     }];
}
@end

The problem happens when I use a custom class (or referencing outlet or add a send event on button).

What is wrong?

edit: I think that I need populate my interface using my custom class because the static content is being lost. Is it possible to be the cause of content being lost?

Dylan

You have two options when it comes to UITableView and Interface Builder. You can have a dynamic table view (pretty common) where your code overrides UITableViewController methods like "numberOfRowsInSection" and "cellForRowAtIndexPath". The other option is a static tableview, and that seems like what you want to do (especially since you haven't overridden the two aforementioned methods, and leads to your blank table). My guess is you need to select "static" for the tableview as shown in the third screenshot in this tutorial.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

When I use custom stars for Android RatingBar, always show half star for decimal values below 0.5

来自分类Dev

Should I wrap my class custom exceptions in my class?

来自分类Dev

How to use a custom binding to animate elements being added using "foreach" in Knockout.js

来自分类Dev

I can "pickle local objects" if I use a derived class?

来自分类Dev

How do I clear/reset date field when using jquery datepicker

来自分类Dev

ObjectDisposedException when I try to use an Image source

来自分类Dev

Should I use a pointer when dealing with lists?

来自分类Dev

function not being overridden in child class

来自分类Dev

使用程序创建的UITableView的Swift Custom UITableViewCell

来自分类Dev

I'm getting an error "invalid use of incomplete type 'class map'

来自分类Dev

How do I use an extension function in another class? C#

来自分类Dev

Can I show a custom Local notification View or an Custom Alert view when app is in Background?

来自分类Dev

Why can't I use alias from a base class in a derived class with templates?

来自分类Dev

fireEvent from Custom class

来自分类Dev

Try and catch blocks: whether in the class itself or when I call the method outside the class

来自分类Dev

Safely storing credentials when I need to retrieve the password for use

来自分类Dev

When should I use val x = fn as opposed to fun x

来自分类Dev

How do I reset an Android spinner?

来自分类Dev

Can I use a custom iOS UI for logging in to the user's google drive account?

来自分类Dev

Use NSViewController with Custom View

来自分类Dev

How can a custom receiver use the "ramp" namespace or can I modify the sample apps to use a custom namespace without re-writing support for RAMP?

来自分类Dev

How to make a custom widget editable only when i click 'Edit' button?

来自分类Dev

Why don't I get correct result when I use original parseList function in Kotlin?

来自分类Dev

How can I define an UUID for a class, and use __uuidof, in the same way for g++ and Visual C++?

来自分类Dev

How can i enable true ToolStripMenuItem in form1 when backgroundworker completed his operation in a new class?

来自分类Dev

An example of the use of the Point class?

来自分类Dev

Use decodable for custom json decoding

来自分类Dev

Reset countdown timer in Android when switching between activities

来自分类Dev

Why does ACHartEngine LineGraph doesn^t show me any Graph when i use API 10

Related 相关文章

  1. 1

    When I use custom stars for Android RatingBar, always show half star for decimal values below 0.5

  2. 2

    Should I wrap my class custom exceptions in my class?

  3. 3

    How to use a custom binding to animate elements being added using "foreach" in Knockout.js

  4. 4

    I can "pickle local objects" if I use a derived class?

  5. 5

    How do I clear/reset date field when using jquery datepicker

  6. 6

    ObjectDisposedException when I try to use an Image source

  7. 7

    Should I use a pointer when dealing with lists?

  8. 8

    function not being overridden in child class

  9. 9

    使用程序创建的UITableView的Swift Custom UITableViewCell

  10. 10

    I'm getting an error "invalid use of incomplete type 'class map'

  11. 11

    How do I use an extension function in another class? C#

  12. 12

    Can I show a custom Local notification View or an Custom Alert view when app is in Background?

  13. 13

    Why can't I use alias from a base class in a derived class with templates?

  14. 14

    fireEvent from Custom class

  15. 15

    Try and catch blocks: whether in the class itself or when I call the method outside the class

  16. 16

    Safely storing credentials when I need to retrieve the password for use

  17. 17

    When should I use val x = fn as opposed to fun x

  18. 18

    How do I reset an Android spinner?

  19. 19

    Can I use a custom iOS UI for logging in to the user's google drive account?

  20. 20

    Use NSViewController with Custom View

  21. 21

    How can a custom receiver use the "ramp" namespace or can I modify the sample apps to use a custom namespace without re-writing support for RAMP?

  22. 22

    How to make a custom widget editable only when i click 'Edit' button?

  23. 23

    Why don't I get correct result when I use original parseList function in Kotlin?

  24. 24

    How can I define an UUID for a class, and use __uuidof, in the same way for g++ and Visual C++?

  25. 25

    How can i enable true ToolStripMenuItem in form1 when backgroundworker completed his operation in a new class?

  26. 26

    An example of the use of the Point class?

  27. 27

    Use decodable for custom json decoding

  28. 28

    Reset countdown timer in Android when switching between activities

  29. 29

    Why does ACHartEngine LineGraph doesn^t show me any Graph when i use API 10

热门标签

归档