English 中文(简体)
给Facebook朋友的海报绘图
原标题:Post drawing to Facebook friend

我正在开发一个应用程序,其中我使用Facebook API。 在这个应用程序中有两个Facebook朋友。 第一个朋友将绘制一个设计图,并将其贴在第二个朋友的Facebook 墙上。 第二个朋友将理解这个图画和对第一个朋友的答复。

在我的代码里,我设计了一个设计, 但我不知道如何把它贴在朋友的墙上 用我的应用程序邀请。

以下是设计代码:

- (void)drawRect:(CGRect)rect
{
    prelocation=lastLocation;
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touchOb=[touches anyObject];

    prelocation=[touchOb locationInView:self];

    //Get value of selected button

    NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];

    NSString *value= [defaults objectForKey:@"clickValue"];

    NSLog(@" value of flag is %@",value);


    if([value isEqualToString:@"yes"])
    {
        NSLog(@" in Erasing");

        CGRect rect1=CGRectMake(prelocation.x,prelocation.y,4,4);

        UIView *view1=[[UIView alloc] initWithFrame:rect1];

        view1.backgroundColor=[UIColor whiteColor];

        [self addSubview:view1]; 
    }
    else
    {   
        if(inkIndicator.value>0.0)
        {
            NSLog(@" in drawing");

            CGRect rect1=CGRectMake(prelocation.x,prelocation.y,2,2);

            UIView *view1=[[UIView alloc] initWithFrame:rect1];

            view1.backgroundColor=[UIColor blueColor];

            [self addSubview:view1];

            counter++;

        } 
        if(counter==10)
        {
            inkIndicator.value--;
            counter=0;
        }
    }

    [self setNeedsDisplay];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touchOb=[touches anyObject];

    lastLocation=[touchOb locationInView:self];

    //    NSLog(@"in start slidr value is %f",drawController.inkIndicator.alpha);

    //Get value of selected button


    NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];

    NSString *value= [defaults objectForKey:@"clickValue"];

    NSLog(@" value of flag is %@",value);


    if([value isEqualToString:@"yes"])
    {
        NSLog(@" in Erasing");

        CGRect rect1=CGRectMake(prelocation.x,prelocation.y,4,4);

        UIView *view1=[[UIView alloc] initWithFrame:rect1];

        view1.backgroundColor=[UIColor whiteColor];

        [self addSubview:view1]; 
    }
    else
    {
        if(inkIndicator.value>0.0)
        {
            NSLog(@" in drawing");

            CGRect rect1=CGRectMake(prelocation.x,prelocation.y,2,2);

            UIView *view1=[[UIView alloc] initWithFrame:rect1];

            view1.backgroundColor=[UIColor blueColor];

            [self addSubview:view1];

            counter++;

            NSLog(@" slidr value is %f",inkIndicator.value);
        }

        if(counter==10)
        {
            inkIndicator.value--;
            counter=0;
        }

    }

    [self setNeedsDisplay];
}

我在小矩形的帮助下画画,怎么贴?

问题回答

You will have to create a UIImage The easiest way is to capture the UIView into a UIImage, please use the following code

-(UIImage*)captureScreen:(UIView*) viewToCapture
{
    //UIGraphicsBeginImageContext(viewToCapture.bounds.size);
    UIGraphicsBeginImageContextWithOptions(viewToCapture.bounds.size, viewToCapture.opaque, 0.0);
    [viewToCapture.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return viewImage;
}

在您创建 UIIMage 后, 您需要将其发送到facebook, 请参看 这个问题的答案 < a href=> https://stackoverflow.com/ questions 5977684/iphone-sending- an- image- with- sharekit- to- facebook > iPhone - 与 Sharekit 一起发送图像到 Facebook





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签