0
我有一個代碼在viewDidLoad和其他方法,我想重新加載它們,如果我點擊一個按鈕,我已經嘗試setNeedDisplay但它不工作,我不知道如果我在右邊使用它SENS?我如何重新加載我的UIViewController?
在viewDidLoad中這是我的代碼:
- (void)viewDidLoad
{
// Create the UISegmentedControler "Next Review" and "Previouse Review"
UISegmentedControl *paginateReviewSegment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Précedent",@"Suivant", nil]];
paginateReviewSegment.segmentedControlStyle = UISegmentedControlStyleBar;
[paginateReviewSegment addTarget:self action:@selector(paginateReviews:) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *paginateBarButton = [[UIBarButtonItem alloc] initWithCustomView:paginateReviewSegment];
self.navigationItem.rightBarButtonItem = paginateBarButton;
[super viewDidLoad];
// Get the review selected
entryReview = [[entriesReview getEntries] objectAtIndex:self.reviewSelected];
// Resize the UIScrollView
[self.scrollView setScrollEnabled:YES];
[self.scrollView setContentSize:self.contentView.frame.size];
// Add UIView "Content" to UIScrollView
[self.scrollView addSubview:self.contentView];
// Set the user name
userNameLabel.text = entryReview.userName;
.....
}
這是我要使用重新加載的UIView動作:
- (void)paginateReviews:(UISegmentedControl*)sender
{
if (sender.selectedSegmentIndex == 0 && self.reviewSelected != 0)
{
self.reviewSelected -= 1;
entryReview = [[entriesReview getEntries] objectAtIndex:self.reviewSelected];
[self.view setNeedsDisplay];
} else if(sender.selectedSegmentIndex == 0 && self.reviewSelected != ([entriesReview entriesCount] - 1))
{
self.reviewSelected += 1;
entryReview = [[entriesReview getEntries] objectAtIndex:self.reviewSelected];
}
}