1

そのため、私はアプリストアにあるアプリの重要な更新に取り組んでいます。タブバーとナビゲーションコントローラーを備えたアプリがあります。ユーザーがリストからアイテムを選択すると、サーバーから送信されたxmlファイルから取得したリンクがWebビューのみの詳細ビューコントローラーに送信されます。私が抱えている問題は、ユーザーがそのタブのルートビューであるテーブルビューに戻ったときに、詳細ビューが解放されていないことです。アプリで他のオプションを選択しても、詳細ビューは変更されません。私のデータがuisharedアプリケーションデータから解放されていないわけではありませんが、ビューは解放されていません。私はここにこのような似たようなアイテムがたくさんあることを知っています、そして私はそれらのすべてを試しました。私はあなたに私のコードのいくつかを与え、他のヒントやコツに大いに感謝します。Im 15で、開発を始めたばかりなので、どんな情報でも役に立ちます。これが私が誰かが助けるために必要だと思うコードです。

TableViewController

- (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];
}

DetailViewController:

#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までメールでお問い合わせください。

4

2 に答える 2

2

detailViewControllerページでWebビューを解放しないでください。代わりに、 [webView loadRequest:requestobj];viewDidLoadではなくviewDidAppear()に配置してください。

また、移行をスムーズにする1つの方法として、次の変更を行います。

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];

する必要があります:

VideoDetailViewController *aBookDetail = [[VideoDetailViewController alloc]     initWithNibName:@"VideosDetailView" bundle:[NSBundle mainBundle]] ;
[self.navigationController pushViewController:videoDetailViewController animated:YES];
[aBookDetail release];
于 2012-06-11T01:02:09.973 に答える
0

Anna Billstromのおかげで、私もviewDidAppearの代わりに使用する必要があることに気づきましたviewDidLoad。これは、テーブルビューからアイテムを選択したときに、外部データクラスを介してコントローラーにデータを渡すためです。したがって、詳細ビューコントローラは、外部データクラスからロードするデータが存在する前にロードされています。viewDidAppearは、セルが選択され、外部クラスにデータがある後にビューが読み込まれるとデータを取得することで、この問題を解決します。

于 2013-07-03T05:05:51.573 に答える