IPhone应用程序视图转换变得急促
我有一个视图,其中包含使用原型单元格的UITableView。它包含一些我连接到interface builder中的子类UITableViewCell的标签 当我单击一行时,我已经在情节提要中创建了一个到详细视图的序列。该视图也可以通过另一个类的segue访问 我的表格和详图视图使用导航控制器 我的问题是,当我多次从表视图转换到细节视图并再次转换时,我注意到过了一段时间后,从细节视图转换回表视图开始变得不稳定。表格滚动也开始有点不平稳 我用的是ARC 如果有人能告诉我什么可能导致这种情况,或者我应该使用什么工具来调查,我将不胜感激 我会写下我的一些源代码以备不时之需。如果还有什么需要我提供的,请告诉我 表视图是从远程服务填充的,但是问题发生在表已经填充并且我不再调用该服务之后 表视图标题:IPhone应用程序视图转换变得急促,iphone,objective-c,ios,performance,Iphone,Objective C,Ios,Performance,我有一个视图,其中包含使用原型单元格的UITableView。它包含一些我连接到interface builder中的子类UITableViewCell的标签 当我单击一行时,我已经在情节提要中创建了一个到详细视图的序列。该视图也可以通过另一个类的segue访问 我的表格和详图视图使用导航控制器 我的问题是,当我多次从表视图转换到细节视图并再次转换时,我注意到过了一段时间后,从细节视图转换回表视图开始变得不稳定。表格滚动也开始有点不平稳 我用的是ARC 如果有人能告诉我什么可能导致这种情况,或者
#import <UIKit/UIKit.h>
#import "SearchManager.h"
@interface SearchViewController : UIViewController <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource, FreeTextSearchClient>
@property (nonatomic, retain) IBOutlet UITableView *TableView;
@end
#import <UIKit/UIKit.h>
#import "Location.h"
#import "RatingTableCellViewController.h"
@interface LocationViewController : UITableViewController <RatingTableViewDelegate>
@property (retain, nonatomic) Location *location;
@property (retain, nonatomic) IBOutlet UITableViewCell *averageRatingCell;
@property (retain, nonatomic) IBOutlet RatingTableCellViewController *yourRatingCell;
@property (retain, nonatomic) IBOutlet UILabel *ratingLabel;
@property (retain, nonatomic) IBOutlet UILabel *address;
@end
表格单元格标题:
#import <UIKit/UIKit.h>
@protocol RatingTableViewDelegate <NSObject>
@required
- (void) changeCommentCellHeight:(int) height;
- (void) setEditingOffset;
- (void) removeEditingOffset;
@end
@interface RatingTableCellViewController : UITableViewCell <UITextViewDelegate>
@property (nonatomic, unsafe_unretained) id <RatingTableViewDelegate> tableViewDelegate;
@property (nonatomic, assign) bool hasRating;
@property (nonatomic, assign) float rating;
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, retain) IBOutlet UILabel *yourRatingLabel;
@property (nonatomic, retain) IBOutlet UITextView *textView;
@property (nonatomic, retain) IBOutlet UIImageView *star1;
@property (nonatomic, retain) IBOutlet UIImageView *star2;
@property (nonatomic, retain) IBOutlet UIImageView *star3;
@property (nonatomic, retain) IBOutlet UIImageView *star4;
@property (nonatomic, retain) IBOutlet UIImageView *star5;
- (IBAction) submitClicked:(id)sender;
- (IBAction) cancelClicked:(id)sender;
- (void) openCell;
- (void) closeCell;
- (void) cancelRating;
@end
#import <UIKit/UIKit.h>
#import "Location.h"
#import "RatingTableCellViewController.h"
@interface LocationViewController : UITableViewController <RatingTableViewDelegate>
@property (retain, nonatomic) Location *location;
@property (retain, nonatomic) IBOutlet UITableViewCell *averageRatingCell;
@property (retain, nonatomic) IBOutlet RatingTableCellViewController *yourRatingCell;
@property (retain, nonatomic) IBOutlet UILabel *ratingLabel;
@property (retain, nonatomic) IBOutlet UILabel *address;
@end
#import "LocationViewController.h"
#import "StarRatingDisplay.h"
#import "RatingViewController.h"
#import "RatingTableCellViewController.h"
@interface LocationViewController ()
@end
@implementation LocationViewController
@synthesize location;
@synthesize averageRatingCell, yourRatingCell;
@synthesize ratingLabel;
@synthesize address;
int commentCellHeight = 45;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewWillAppear:(BOOL)animated {
[self showStarRating:averageRatingCell];
ratingLabel.Text = [NSString stringWithFormat: @"%d Rating%@:", location.Ratings, location.Ratings != 1 ? @"s" : @""];
self.navigationItem.title = location.Name;
address.text = location.Address.description;
address.lineBreakMode = UILineBreakModeWordWrap;
address.numberOfLines = 5;
yourRatingCell.tableViewDelegate = self;
// Show the nav bar. It might be hidden if coming from search view.
[self.navigationController setNavigationBarHidden:false];
}
- (void) setEditingOffset {
[self.tableView setContentOffset:CGPointMake(0, 60)];
}
- (void) removeEditingOffset {
[self.tableView setContentOffset:CGPointMake(0, 0)];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0 && indexPath.row == 1) {
return commentCellHeight;
}
else if(indexPath.section == 1 && indexPath.row == 0) {
return 70;
}
return 45;
}
- (void) changeCommentCellHeight:(int) height {
commentCellHeight = height;
[self.tableView beginUpdates];
[self.tableView endUpdates];
}
- (void)showStarRating:(UITableViewCell*) cell {
int x = 132;
int y = 12;
//add rating
NSArray *stars = [StarRatingDisplay GetStarsForScore:location.Score];
NSEnumerator *enumerator = [stars objectEnumerator];
UIImage *thisStar;
int i = 0;
//create image views for stars and place them on the callout
while(thisStar = [enumerator nextObject]) {
UIImageView *view = [[UIImageView alloc] initWithImage:thisStar];
view.frame = CGRectMake(x+(thisStar.size.width + 2)*i, y, thisStar.size.width, thisStar.size.height);
[cell.contentView addSubview:view];
i++;
}
}
- (void) viewWillDisappear:(BOOL)animated {
//reset the comment/rating cell height
NSIndexPath *commentPath = [NSIndexPath indexPathForRow:1 inSection: 0];
RatingTableCellViewController *ratingCell = (RatingTableCellViewController*)[self.tableView cellForRowAtIndexPath:commentPath];
[ratingCell cancelRating];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end