일부 정적 셀이 포함 된 UITableView가 있습니다. 그 중 하나가 만졌을 때 UIActionSheet를 보여줍니다. 여기에 코드가 있습니다 :이상한 동작 UIActionSheet + UITableView : 행이 사라짐
viewDidLoad : 컨트롤을 초기화하십시오.
- (void)viewDidLoad
{
[super viewDidLoad];
[self initializeControls];
}
initializeControls : 셀 내의 레이블에 제스처 인식기를 추가하여 UIActionSheet를 표시합니다.
- (void)initializeControls {
[...]
// Places Label
self.placeNamesLabel.userInteractionEnabled = YES;
tapGesture = \
[[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(didPlaceNamesLabelWithGesture:)];
[self.placeNamesLabel addGestureRecognizer:tapGesture];
tapGesture = nil;
[...]
}
didPlaceNamesLabelWithGesture : UIActionSheet를 초기화 스토리 보드에서 jQuery과하고 닫기 버튼을 추가합니다.
- (void)didPlaceNamesLabelWithGesture:(UITapGestureRecognizer *)tapGesture
{
// Show UITableView in UIActionView for selecting Place objects.
placesActionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[placesActionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect tableFrame = CGRectMake(0, 40, 0, 0);
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
AddArticlesPlacesViewController *placesView = [storyBoard instantiateViewControllerWithIdentifier:@"PlacesForArticle"];
placesView.managedObjectContext = self.managedObjectContext;
placesView.view.frame = tableFrame;
[placesActionSheet addSubview:placesView.view];
placesView = nil;
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissPlacesActionSheet:) forControlEvents:UIControlEventValueChanged];
[placesActionSheet addSubview:closeButton];
closeButton = nil;
[placesActionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[placesActionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}
dismissPlacesActionSheet : close UIActionSheet.
-(void)dismissPlacesActionSheet:(id)sender {
[placesActionSheet dismissWithClickedButtonIndex:0 animated:YES]; }
모든 것이 작동하고 UITableView가 Core Data에서 정상적으로 채 웁니다. 그렇다면 문제는 어디에 있습니까? 요점은 어떤 행을 두드리면 테이블 전체가 비어있는 것입니다 (아직 이미지를 게시 할 수 없습니다, 죄송합니다).
AddArticlesPlacesViewController에 밀어 넣기 (push segue)를 발생시키는 버튼이있는 새로운 사용자 정의 행을 추가하려고했습니다. 이 잘 작동하고 예상대로 동작입니다. 그래서 문제는 UIActionSheet와 UITableView 사이에 있습니다.
두보기 컨트롤러의 인터페이스는 다음과 같습니다.
메인.
@interface AddArticleViewController : UITableViewController <NSFetchedResultsControllerDelegate, [...]>
[...]
@property (weak, nonatomic) IBOutlet UILabel *placeNamesLabel;
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
[...]
@end
보조.
@interface AddArticlesPlacesViewController : UITableViewController <NSFetchedResultsControllerDelegate>
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@end
막혔습니다. 내가 도대체 뭘 잘못하고있는 겁니까?
감사합니다.
Pedro Ventura.
때문에 placesView 관리 개체 컨텍스트와 placesView = 전무? –
@verbumdei : UITableView는 두 가지 솔루션 (내부 및 외부 UIActionSheet)에서 핵심 데이터의 데이터를 표시하고 있다고 생각합니다. – Pedro