因此,我正在对应用商店中的应用进行重要更新。我有一个带有标签栏和导航控制器的应用程序。当用户从列表中选择一个项目时,它会将它从我的服务器发送的 xml 文件中获取的链接发送到仅是 Web 视图的详细视图控制器。我遇到的问题是当用户返回到作为该选项卡的根视图的 tableview 时,详细视图没有被释放。当您在应用程序中选择其他选项时,详细视图不会更改。不是我的数据没有从 uishared 应用程序数据中释放,而是视图没有释放。我知道这里有很多类似的东西,我都试过了。我会给你一些我的代码,并非常感谢其他提示和技巧。我 15 岁,刚刚进入开发阶段,所以任何信息都有帮助。这是我认为任何人都需要帮助的代码。
表视图控制器
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
NSString * storyLink = [[stories objectAtIndex: storyIndex] objectForKey: @"link"];
// clean up the link - get rid of spaces, returns, and tabs...
storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
storyLink = [storyLink stringByReplacingOccurrencesOfString:@"\n" withString:@""];
storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
videoDetailViewController.title = @"Videos";
ExampleAppDataObject* theDataObject = [self theAppDataObject];
theDataObject.videoData = storyLink;
if (self.videoDetailViewController == nil)
{
VideoDetailViewController *aBookDetail = [[[VideoDetailViewController alloc] initWithNibName:@"VideosDetailView" bundle:[NSBundle mainBundle]] autorelease];
self.videoDetailViewController = aBookDetail;
[aBookDetail release];
aBookDetail = nil;
}
[self.navigationController pushViewController:videoDetailViewController animated:YES];
}
细节视图控制器:
#import "VideoDetailViewController.h"
#import "RSSEntry.h"
#import "ExampleAppDataObject.h"
#import "AppDelegateProtocol.h"
@implementation VideoDetailViewController
@synthesize activityIndicator;
@synthesize webView;
@synthesize pasteboard;
- (ExampleAppDataObject*) theAppDataObject;
{
id<AppDelegateProtocol> theDelegate = (id<AppDelegateProtocol>) [UIApplication sharedApplication].delegate;
ExampleAppDataObject* theDataObject;
theDataObject = (ExampleAppDataObject*) theDelegate.theAppDataObject;
return theDataObject;
}
- (void)viewDidLoad
{
ExampleAppDataObject* theDataObject = [self theAppDataObject];
NSString *urladdress = theDataObject.videoData;
NSURL *url = [NSURL URLWithString:urladdress];
NSURLRequest *requestobj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestobj];
pasteboard = [UIPasteboard generalPasteboard];
[super viewDidLoad];
}
- (void)dealloc
{
[webView release];
webView = nil;
[activityIndicator release];
[pasteboard release];
[VideoDetailViewController release];
[urlData release];
urlData = nil;
[super dealloc];
}
@end
我跳过了很多我觉得不必要的代码。如果您想要实际文件,请发送电子邮件至 evan.stoddard@me.com