내 TableView 앱용 사용자 정의 셀이 있습니다. TableViewController는 "BlogView"라고합니다. 내 사용자 정의 셀에는 몇 개의 버튼이 있습니다. 하나는 공유 버튼입니다. 단추 중 하나가 눌려지면 UIActivityViewController를 표시하려고합니다. 내 사용자 지정 셀의 헤더에 사용자 정의 셀에서 ActivityViewController 호출
, 나는 속성이 있습니다 사용자 정의 셀에@property (nonatomic, retain) BlogView *myViewController;
을, 나는 layoutSubview 위해 가지고 : 내가 가지고있는 선택 didTapCommentButtonAction를 들어
self.commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.commentButton addTarget:self action:@selector(didTapCommentButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[self.commentButton setTitle:@"Share" forState:UIControlStateNormal];
[self.commentButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[self.commentButton setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
:
- (void)didTapCommentButtonAction:(id)sender
{
NSLog(@"CommentButtonTAPPED");
Mail *mail = [[Mail alloc]init];
NSString *html = self.prayerObject[@"Request"];
NSString *thetitle = [self.prayerObject[@"Title"] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSString *thedate = self.prayerObject[@"dateMade"];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MMM_dd_yyyy"];
[dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
NSDate *theNewDate1 = [dateFormat dateFromString:thedate];
NSString *theNewDate = [dateFormat stringFromDate:theNewDate1];
mail.thehtml = html;
self.nameofhtmlfile = [[[[@"http://www.iprayed4u.net/app/" stringByAppendingString:thetitle] stringByAppendingString:@"_"] stringByAppendingString:theNewDate] stringByAppendingString:@".html"];
// Reminder *thereminder = [[Reminder alloc] init];
//thereminder.thehtml = html;
//thereminder.thetitle = thetitle;
//thereminder.thedate = thedate;
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[self] applicationActivities:@[mail]];
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
activityVC.excludedActivityTypes = @[ UIActivityTypePostToWeibo,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeMail,
UIActivityTypePrint
];
}
else {
activityVC.excludedActivityTypes = @[ UIActivityTypePostToWeibo,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeMail,
UIActivityTypePrint,
UIActivityTypeAirDrop
];
}
NSLog(@"Test");
[self.myViewController presentViewController: activityVC animated: YES completion: nil];
}
블로그보기
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object
{
static NSString *CellIdentifier = @"Cell";
Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[Cell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
self.theObject = object;
// Configure the cell to show todo item with a priority at the bottom
cell.profileName.text = object[@"Title"];
cell.contentLabel.text = object[@"Request"];
cell.firstName = object[@"FirstName"];
cell.lastName = object[@"LastName"];
cell.iostoken = object[@"DeviceID"];
cell.request = object[@"Title"];
cell.prayerObject = object;
PFFile *thumbnail = object[@"ProfilePic"];
cell.profilePic.image = [UIImage imageNamed:@"[email protected]"];
[thumbnail getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
UIImage *thumbnailImage = [UIImage imageWithData:imageData];
UIImageView *thumbnailImageView = [[UIImageView alloc] initWithImage:thumbnailImage];
cell.profilePic.image = thumbnailImage;
}];
NSString *dates = object[@"dateMade"];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMM_dd_yyyy"];
NSDate *datefromstring = [formatter dateFromString:dates];
NSDateFormatter *formatter2 = [[NSDateFormatter alloc] init];
[formatter2 setDateFormat:@"MMM dd, yyyy"];
cell.dateLabel.text = [formatter2 stringFromDate:datefromstring];
UIFont *cellFont = [UIFont fontWithName:@"Verdana-Bold" size:15];
UIFont *cellFont2 = [UIFont fontWithName:@"Verdana-Bold" size:12];
return cell;
}
경고 나 오류는 표시되지 않지만 버튼을 클릭해도 아무런 변화가 없습니다.
다른 코드가 있습니까? 난 당신이 사용자 정의 셀 클래스 내부에 귀하의 버튼에 대한 속성이 필요하다고 생각해. 그런 다음 해당 속성 단추에 선택기를 추가 할 수 있습니다. 선택기 메서드 내에서 ActivityViewController를 시작할 수 있습니다. –
presentViewController는 버튼이 호출하는 선택기 메서드 안에 있습니다. @JoshEngelsma – user717452
myViewController 란 무엇이며, avc는 무엇입니까? 그 중 하나에 대한 참조를 만들거나 참조를 얻습니까? – rdelmar