UITableView返回null?
我花了很多时间研究这个问题,但仍然找不到解决方案。下面是一张关于用户经历的图表:
- 用户拍摄一张照片或从相机胶卷中拍摄一张
- 一旦拍摄(或选择)一张照片,captionView 就会关闭
- 一旦 CaptionView 关闭,就会开始从不同的视图开始上传
- 如果用户决定打开 startUploads 所在的视图,他们可以看到已上传的内容
现在您已经了解了该过程的一些信息,我有一些问题。上传完成后我希望它们淡出。我知道如何做到这一点,但由于某种原因,当我调用时,self.theTableView
返回 null。我的 .h 中有一个 @property(nonatomic,retain)...
,我的 .m 中有一个 @sythesize theTableView;
。
在另一个问题中,我发现在执行 startUploads 时,需要在这里启动我的 NSMutableArray (所以我认为它会对我的 UItableView 执行相同的操作)。这就是我所拥有的:
- (id)initWithNibNamed:(NSString *)nibName bundle:(NSBundle *)bundle {
self = [super initWithNibNamed:nibName bundle:bundle];
if (self) {
processList = [[NSMutableArray alloc] init];
self.theTableView = [[UITableView alloc] init];
NSLog(@"thetableview: %@", theTableView);
}
return self;
}
以防万一您想了解如何调用 startUploads
,这里是代码:
processViewController *testtest = [[processViewController alloc] initWithNibName:@"processView.xib" bundle:nil];
//testtest.processList = [[NSMutableArray alloc] initWithNig];
NSLog(@"Different:displayProcessVC BEFORE STARTING UPLOAD, processList = %@", testtest.processList);
NSLog(@"Different:displayProcessVC BEFORE STARTING UPLOAD, theTableView = %@", testtest.theTableView);
[testtest startUploads];
NSLog(@"Different:displayProcessVC AFTER STARTING UPLOAD, processList = %@", testtest.processList);
NSLog(@"Different:displayProcessVC AFTER STARTING UPLOAD, theTableView = %@", testtest.theTableView);
[testtest release];
但是它仍然在控制台中显示 (null)
。
请帮忙!
Coulton
编辑 1:
这是零的地方:
- (void)deleteOneRow: (NSString *)theString {
int theInt = [processList indexOfObject:theString];
[processList removeObjectAtIndex:theInt];
NSArray *deleteIndexPaths = [[NSArray alloc] initWithObjects: [NSIndexPath indexPathForRow:theInt inSection:0], nil];
NSLog(@"theTableView: %@", self.theTableView);
[self.theTableView beginUpdates];
[self.theTableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.theTableView endUpdates];
}
I have spent many hours looking into this and I still can't find a solution. Here's a chart on what the user goes through:
- The user takes a picture or takes one from their camera roll
- As soon as they take (or select) one, the captionView closes
- As soon as the captionView closes, startUploads from a different view starts
- If the user decides to open the view that startUploads is in, they can see what has been uploaded
Now that you know a little bit about the process, I have a few issues. When uploads finish I want them to fade out. I know how to do that, but for some reason when I call to, the self.theTableView
returns null. I have a @property (nonatomic, retain)...
in my .h and I have a @sythesize theTableView;
in my .m.
In a different question, I found out that when doing the startUploads
, my NSMutableArray needed to be initiated in here (so I thought that it would do the same with my UItableView). Here's what I have:
- (id)initWithNibNamed:(NSString *)nibName bundle:(NSBundle *)bundle {
self = [super initWithNibNamed:nibName bundle:bundle];
if (self) {
processList = [[NSMutableArray alloc] init];
self.theTableView = [[UITableView alloc] init];
NSLog(@"thetableview: %@", theTableView);
}
return self;
}
Just in case you want to see how startUploads
is called, here's the code:
processViewController *testtest = [[processViewController alloc] initWithNibName:@"processView.xib" bundle:nil];
//testtest.processList = [[NSMutableArray alloc] initWithNig];
NSLog(@"Different:displayProcessVC BEFORE STARTING UPLOAD, processList = %@", testtest.processList);
NSLog(@"Different:displayProcessVC BEFORE STARTING UPLOAD, theTableView = %@", testtest.theTableView);
[testtest startUploads];
NSLog(@"Different:displayProcessVC AFTER STARTING UPLOAD, processList = %@", testtest.processList);
NSLog(@"Different:displayProcessVC AFTER STARTING UPLOAD, theTableView = %@", testtest.theTableView);
[testtest release];
However it still shows (null)
in the console.
Please help!
Coulton
EDIT 1:
Here's where it's being nil:
- (void)deleteOneRow: (NSString *)theString {
int theInt = [processList indexOfObject:theString];
[processList removeObjectAtIndex:theInt];
NSArray *deleteIndexPaths = [[NSArray alloc] initWithObjects: [NSIndexPath indexPathForRow:theInt inSection:0], nil];
NSLog(@"theTableView: %@", self.theTableView);
[self.theTableView beginUpdates];
[self.theTableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.theTableView endUpdates];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UITableView 的指定初始值设定项是
-initWithFrame:style:
并且您正在泄漏。请在-viewDidLoad
中尝试此操作。self.theTableView = [[[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain] autorelease];
The designated initializer for UITableView is
-initWithFrame:style:
and you're leaking. Try this in-viewDidLoad
instead.self.theTableView = [[[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain] autorelease];