如果您能帮助我解决问题,我将不胜感激,那么您
提前致谢 !

我的问题1

然后,如果我不知道我是否能够更改UIativity
我还有其他错误。 。

我的错误是:“ AcceptView”没有可见的@interface声明选择器presentViewController:animated:completion:

我的问题2
我不知道如何更改连接按钮下方的代码

我想使用此代码连接按钮
该做的?

  // partager button
    self.buttonshera = [[UIButton alloc] init];
    [self.buttonshera setBackgroundImage:[UIImage imageNamed:@"buttonorange.png"] forState:UIControlStateNormal];
    [self.buttonshera setAlpha:0.9];
    [self.buttonshera.titleLabel setTextColor:[UIColor whiteColor]];
    [self.buttonshera setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.buttonshera.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [self.buttonshera setTitle:[NSLocalizedString(@"buttonshera", nil) uppercaseString] forState:UIControlStateNormal];
    [self.buttonshera setFrame:CGRectMake(global.xmargin, ypositionstart + 60, global.bodywidth, 32)];
     [self addSubview:self.buttonshera];

    [buttonshera addTarget:self
                 action:@selector(didSelectShare)
       forControlEvents:UIControlEventTouchUpInside];


我想连接这个

#pragma mark - Actions

- (void)didSelectShare:(id)sender {
    NSMutableArray *activityItems = [NSMutableArray array];

    NSString *htmlBody = @"<html><body><h1>Customized body</h1></body></html>";

    //  For Mail
    [activityItems addObject:[WHMailActivityItem mailActivityItemWithSelectionHandler:^(MFMailComposeViewController *mailController) {
        [mailController setSubject:@"Hey it's a subject!"];
        [mailController setMessageBody:htmlBody isHTML:YES];
        [mailController addAttachmentData:[htmlBody dataUsingEncoding:NSUTF8StringEncoding]
                                 mimeType:@"text/html"
                                 fileName:@"Awesome Attachment.html"];
        mailController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    }]];

    //  For texting
    [activityItems addObject:[WHTextActivityItem textActivityItemWithSelectionHandler:^(MFMessageComposeViewController *messageController) {
        [messageController setBody:@"My super awesome message for texting only!"];
        messageController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    }]];

    //  For everything else
    [activityItems addObject:@"Some boring text that should be copied..."];

    NSArray *activities = (@[
                             [[WHMailActivity alloc] init],
                             [[WHTextActivity alloc] init]   // keep in mind that texting is broken on the simulator...
                             ]);

    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems
                                                                                     applicationActivities:activities];
    activityController.excludedActivityTypes = (@[
                                                  UIActivityTypeAssignToContact,
                                                  UIActivityTypeMail,
                                                  UIActivityTypeMessage,
                                                  UIActivityTypePrint,
                                                  UIActivityTypeSaveToCameraRoll
                                                  ]);

    [self presentViewController:activityController animated:YES completion:NULL];
}


这个.h

#import <UIKit/UIKit.h>
#import "Globales.h"

#import "Tools.h"

@interface AcceptView : UIScrollView
{
    Globales *global;

    UITextView *descriptionView;
    UIButton *startmission;
    UIButton *buttonshera;
}

@property(nonatomic, retain) UITextView *descriptionView;
@property(nonatomic, retain) UIButton *startmission;
@property(nonatomic, retain) UIButton *buttonshera;


@end


这个.m

#import "AcceptView.h"
#import "WHMailActivity.h"
#import "WHTextActivity.h"
#import "WHMailActivityItem.h"
#import "WHTextActivityItem.h"

@interface AcceptView ()
@end

@implementation AcceptView

@synthesize startmission=_startmission;
@synthesize buttonshera=_buttonshera;
@synthesize descriptionView=_descriptionView;


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        global = [Globales getInstance];

        [self setShowsHorizontalScrollIndicator:NO];
        [self setShowsVerticalScrollIndicator:NO];
        [self setBounces:YES];

        self.descriptionView = [[UITextView alloc] init];
        [self.descriptionView setBackgroundColor:[UIColor clearColor]];
        [self.descriptionView setOpaque:NO];
        [self.descriptionView setFont:[UIFont systemFontOfSize:13]];
        [self.descriptionView setTextAlignment:NSTextAlignmentJustified];
        [self.descriptionView setUserInteractionEnabled:NO];

        [self.descriptionView setText:[Globales getInstance].missionSelected.oneDescription];
        [self addSubview:self.descriptionView];

        CGFloat fixedWidth = global.bodywidth;
        CGSize newSize = [self.descriptionView sizeThatFits:CGSizeMake(global.bodywidth, 1000)];
        CGRect newFrame = self.descriptionView.frame;
        newFrame.origin.x = global.xmargin;
        newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
        self.descriptionView.frame = newFrame;

        [self performSelectorOnMainThread:@selector(load) withObject:nil waitUntilDone:YES];
    }

    return self;
}

- (void) load
{
    int ypositionstart = self.descriptionView.frame.origin.y + self.descriptionView.frame.size.height + 10;

    // Load pageContent with pageElement
    TcheckitMobileBeanService_missionCustom *mission = global.missionSelected;

    if(mission.onePageContentMain != nil)
    {
        if([mission.onePageContentMain.listPageElement count] > 0){
            for(TcheckitMobileBeanService_pageElement *pageElement in mission.onePageContentMain.listPageElement){
                if([pageElement isKindOfClass:[TcheckitMobileBeanService_pageElementMedia class]]){
                    TcheckitMobileBeanService_pageElementMedia *element = (TcheckitMobileBeanService_pageElementMedia *) pageElement;

                    if(element.oneMedia != nil){
                        CGRect frame = CGRectMake(global.xmargin, ypositionstart, global.bodywidth, 480);
                        UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];

                        [self performSelector:@selector(loadImageInBackground:withMedia:) withObject:imageView withObject:element.oneMedia];

                        ypositionstart = imageView.frame.origin.y + imageView.frame.size.height + 5;
                    }
                }

                if([pageElement isKindOfClass:[TcheckitMobileBeanService_pageElementText class]]){
                    TcheckitMobileBeanService_pageElementText *element = (TcheckitMobileBeanService_pageElementText *) pageElement;

                    if(element.title != nil){
                        UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(global.xmargin, ypositionstart, global.bodywidth, 10)];
                        [textView setEditable:NO];
                        [textView setUserInteractionEnabled:NO];
                        [textView setScrollEnabled:NO];
                        [textView setText:element.title];
                        [textView setBackgroundColor:[UIColor clearColor]];
                        [textView setTextAlignment:NSTextAlignmentJustified];
                        [textView setFont:[UIFont boldSystemFontOfSize:13]];
                        [self addSubview:textView];

                        CGSize newSize = [textView sizeThatFits:CGSizeMake(global.bodywidth, 10000)];
                        CGRect newFrame = textView.frame;
                        newFrame.size = CGSizeMake(fmaxf(newSize.width, global.bodywidth), newSize.height);
                        textView.frame = newFrame;

                        ypositionstart = textView.frame.origin.y + textView.frame.size.height;
                    }

                    if(element.content != nil){
                        UITextView *textViewText = [[UITextView alloc] initWithFrame:CGRectMake(global.xmargin, ypositionstart, global.bodywidth, 10)];
                        [textViewText setEditable:NO];
                        [textViewText setUserInteractionEnabled:NO];
                        [textViewText setScrollEnabled:NO];
                        [textViewText setText:element.content];
                        [textViewText setBackgroundColor:[UIColor clearColor]];
                        [textViewText setTextAlignment:NSTextAlignmentJustified];
                        [textViewText setFont:[UIFont systemFontOfSize:13]];
                        [self addSubview:textViewText];

                        CGSize newSize = [textViewText sizeThatFits:CGSizeMake(global.bodywidth, 10000)];
                        CGRect newFrame = textViewText.frame;
                        newFrame.size = CGSizeMake(fmaxf(newSize.width, global.bodywidth), newSize.height);
                        textViewText.frame = newFrame;

                        ypositionstart = textViewText.frame.origin.y + textViewText.frame.size.height + 5;
                    }
                }
            }
        }
    }
    // accepte button
    self.startmission = [[UIButton alloc] init];
    [self.startmission setBackgroundImage:[UIImage imageNamed:@"buttonorange.png"] forState:UIControlStateNormal];
    [self.startmission setAlpha:0.9];
    [self.startmission.titleLabel setTextColor:[UIColor whiteColor]];
    [self.startmission setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.startmission.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [self.startmission setTitle:[NSLocalizedString(@"startmission", nil) uppercaseString] forState:UIControlStateNormal];
    [self.startmission setFrame:CGRectMake(global.xmargin, ypositionstart + 20, global.bodywidth, 32)];
    [self addSubview:self.startmission];

    // partager button
    self.buttonshera = [[UIButton alloc] init];
    [self.buttonshera setBackgroundImage:[UIImage imageNamed:@"buttonorange.png"] forState:UIControlStateNormal];
    [self.buttonshera setAlpha:0.9];
    [self.buttonshera.titleLabel setTextColor:[UIColor whiteColor]];
    [self.buttonshera setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.buttonshera.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [self.buttonshera setTitle:[NSLocalizedString(@"buttonshera", nil) uppercaseString] forState:UIControlStateNormal];
    [self.buttonshera setFrame:CGRectMake(global.xmargin, ypositionstart + 60, global.bodywidth, 32)];
     [self addSubview:self.buttonshera];

    [buttonshera addTarget:self
                 action:@selector(didSelectShare)
       forControlEvents:UIControlEventTouchUpInside];


}

- (void) loadImageInBackground:(UIImageView *)imageView withMedia:(TcheckitMobileBeanService_media *)media
{
    [Tools saveImage:media withSuffixe:@""];
    UIImage *originalImage = [UIImage imageWithContentsOfFile:media.localPath];
    UIImage *scaledImage = [Tools imageWithImage:originalImage scaledToWidth:global.bodywidth];
    [imageView setImage:scaledImage];
    [imageView setFrame:CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y, global.bodywidth, scaledImage.size.height)];
    [self addSubview:imageView];
}







#pragma mark - Actions

- (void)didSelectShare:(id)sender {
    NSMutableArray *activityItems = [NSMutableArray array];

    NSString *htmlBody = @"<html><body><h1>Customized body</h1></body></html>";

    //  For Mail
    [activityItems addObject:[WHMailActivityItem mailActivityItemWithSelectionHandler:^(MFMailComposeViewController *mailController) {
        [mailController setSubject:@"Hey it's a subject!"];
        [mailController setMessageBody:htmlBody isHTML:YES];
        [mailController addAttachmentData:[htmlBody dataUsingEncoding:NSUTF8StringEncoding]
                                 mimeType:@"text/html"
                                 fileName:@"Awesome Attachment.html"];
        mailController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    }]];

    //  For texting
    [activityItems addObject:[WHTextActivityItem textActivityItemWithSelectionHandler:^(MFMessageComposeViewController *messageController) {
        [messageController setBody:@"My super awesome message for texting only!"];
        messageController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    }]];

    //  For everything else
    [activityItems addObject:@"Some boring text that should be copied..."];

    NSArray *activities = (@[
                             [[WHMailActivity alloc] init],
                             [[WHTextActivity alloc] init]   // keep in mind that texting is broken on the simulator...
                             ]);

    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems
                                                                                     applicationActivities:activities];
    activityController.excludedActivityTypes = (@[
                                                  UIActivityTypeAssignToContact,
                                                  UIActivityTypeMail,
                                                  UIActivityTypeMessage,
                                                  UIActivityTypePrint,
                                                  UIActivityTypeSaveToCameraRoll
                                                  ]);

    [self presentViewController:activityController animated:YES completion:NULL];
}



@end

最佳答案

presentViewController:animated:completion:是仅用于ViewControllers的方法,您正在将它用于不是控制器的ScrollView(AcceptView)类,因此会出现错误,如果要使用AcceptView,则必须将其作为CustomClass加载到ScrollView中无法显示或取消。

关于ios - 'AcceptView'的可见@interface没有声明选择器'presentViewController:animated:completion:',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24952803/

10-09 06:10