小编Paw*_*shi的帖子

如何以编程方式创建的uibutton以编程方式显示弹出窗口(不使用接口构建器)

我有一个我在视图控制器中以编程方式创建的按钮.按下按钮后,我希望它使用一种方法以编程方式创建弹出框.

在我的视图controller.m中的ViewDidLoad中创建的按钮

 UIView *moreFundInfoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 540, 620)];
[self.view addSubview:moreFundInfoView];
[moreFundInfoView setBackgroundColor:[UIColor RMBColor:@"b"]];

btnContact = [UIButton buttonWithType:(UIButtonTypeRoundedRect)];


[btnContact setFrame:CGRectMake(390, 575, contactButton.width, contactButton.height)];
 btnContact.hidden = NO;
[btnContact setTitle:@"Contact" forState:(UIControlStateNormal)];
[moreFundInfoView addSubview:btnContact];

[btnContact addTarget:self action:@selector(showContactDetails:) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)

然后我按下按钮时使用的方法.

-(void) showContactDetails: (id) sender
{
UIViewController *popoverContent = [[UIViewController alloc]init];

UIView *popoverView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 300)];

[popoverView setBackgroundColor:[UIColor RMBColor:@"b"]];

popoverContent.view = popoverView;

popoverContent.contentSizeForViewInPopover = CGSizeMake(200, 300);

UIPopoverController *contactPopover =[[UIPopoverController alloc] initWithContentViewController:popoverContent];

[contactPopover presentPopoverFromRect:btnContact.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES ];

[contactPopover setDelegate:self];
Run Code Online (Sandbox Code Playgroud)

} …

uibutton ios uipopover

15
推荐指数
2
解决办法
3万
查看次数

Facebook原生登录即使安装在设备中也不会打开Facebook应用程序?

我已经按照facebook-iso-sdk 4.8.0 for iOS 9的文档中描述的每个步骤进行了操作,但仍然无法在我的应用程序中使用"login-with-facebook"进行应用程序切换,即使已经安装了facebook app.

正如您在下面的屏幕截图中看到的,我已经修改了info.plist,但仍然无法让本机应用程序切换工作.

我还检查了info.plist值中的错字错误.我可以向你保证他们是对的.

这是我的代码: -

    if (![AppDelegate SharedInstance].login) {
        [AppDelegate SharedInstance].login = [[FBSDKLoginManager alloc] init];
    }
    [AppDelegate SharedInstance].login.loginBehavior = FBSDKLoginBehaviorNative;
    [[AppDelegate SharedInstance].login logInWithReadPermissions:@[@"public_profile",@"email",@"user_friends"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        if (error) {

        }
        else if (result.isCancelled)
        {
            // Handle cancellations
        }
        else
        {
            NSLog(@"result.grantedPermissions == %@",result.grantedPermissions);
            if (result.token)
            {
                [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, email, first_name, last_name"}]
                 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                     if (!error) {
                         NSLog(@"fetched user:%@", result);
                         NSString *userImageURL = [NSString …
Run Code Online (Sandbox Code Playgroud)

objective-c ios facebook-ios-sdk

6
推荐指数
2
解决办法
3721
查看次数

使用UIInput NGUI时如何删除/禁用键盘上的文本框?

我正在使用NGUI的UIInput类来接受来自用户的文本输入.当我开始在移动设备中输入文本框时.出现一个键盘,它自带一个另一个文本框,带有"OK"/"Done"按钮(如果我们谈论iPhone,就像键盘配件视图一样).

我可以禁用键盘中出现的文本框吗?或者它甚至不可能,我只是拍摄空白?

通过搜索我可以收集的一段时间,键盘的外观处理购买Unity的"TouchScreenKeyboard"类.但根据Unity Scripting参考,没有任何东西可以隐藏键盘内的文本字段.

Unity Scripting参考:TouchInputKeyboard

PS: - 我仍然可以通过直接输入文本框中的输入,我只是想要删除键盘内的额外文本框.

为了更清楚,我附上了解释这个的图像

这是屏幕.

在此输入图像描述

当我开始在其中一个文本框中输入内容时.键盘如下所示.正如您所看到的,键盘上方的文本框不是原始文本框.

在此输入图像描述

unity-game-engine ngui

5
推荐指数
1
解决办法
7747
查看次数

为什么这个循环在c中运行无限次?

我只是在C编程中试验代码.并且开始了解一种奇怪的行为.嗯...因为我不是C的专家,所以我不知道它是奇怪的还是正常的.

基本上我的问题是关于以下两行代码之间的区别: -

char a = 'h'; // here variable a is not an array of "char"
Run Code Online (Sandbox Code Playgroud)

char a = 'hi'; //here variable a is not an array of "char" as well (i don't know if compiler assumes it as an array or not but , at least i didn't declared it that way )
Run Code Online (Sandbox Code Playgroud)

我使用了以下代码

第一:-

char a =0;
for(;a<'hi';a++)
{
    printf("%d= hello world \n",a);
}
Run Code Online (Sandbox Code Playgroud)

第二:-

char a;
for(a='h';a<'hi';a++)
{
    printf("%d= hello world \n",a);
}
Run Code Online (Sandbox Code Playgroud)

上面提到的两个循环都在永远运行,

有人可以告诉我为什么这样吗? …

c for-loop char

5
推荐指数
1
解决办法
171
查看次数

如何在Perfect 2.0中获取项目文件夹的根目录路径?

如您所知,对于服务器端而言,完美的2.0框架已经面世。我试图获取根目录的路径,但是还没有任何运气。

片段1

let fileDir = Dir("/Resources/fileuploads")
print(fileDir.path)
Run Code Online (Sandbox Code Playgroud)

这段代码给了我路径

/Resources/fileuploads
Run Code Online (Sandbox Code Playgroud)

片段2

let fileDir = Dir(Dir.workingDir.path + "Resources/fileuploads")
print(fileDir.path)
Run Code Online (Sandbox Code Playgroud)

这段代码给了我路径

/Users/username/Library/Developer/Xcode/DerivedData/projname-acxmbygsjkthxvbigpfoqesstidh/Build/Products/Debug/Resources/fileuploads/
Run Code Online (Sandbox Code Playgroud)

但是,我要指向的实际路径是。

/Users/username/Documents/folderOne/folderTwo/projname/Resources/fileuploads/
Run Code Online (Sandbox Code Playgroud)

哪里

/Users/username/Documents/folderOne/folderTwo/projname
Run Code Online (Sandbox Code Playgroud)

是项目的根文件夹所在的路径。

我如何获得项目根文件夹的路径?

swift perfect

5
推荐指数
3
解决办法
6763
查看次数

替换Swift中的goto语句

如何将控件转移到Swift代码中的特定行?

在Objective-C中,我将使用以下内容执行以下操作 goto

if(a==b)
{
    goto i123;
}
else
{
    goto i456;
}
NSLog(@"the not reachable point");
i123:
NSLog(@"line 123 is here");
int j = 5;
int x = 2+j;
i456:
NSLog(@"line 456 is here");
Run Code Online (Sandbox Code Playgroud)

在斯威夫特唯一的控制转移语句我能找到的是continue,break,fallthrough,和return

continue并且break只能使用循环; return并且fallthrough不要以这种方式转移控制权.

我可以用什么?

编辑:-

Julien __的答案实际上并没有解决我的问题,但它可能是目前唯一可用的选项.所以我接受了Julien的答案.

goto control-flow swift

4
推荐指数
2
解决办法
1万
查看次数

在非静态成员函数错误之外无效使用'this'?

我正在使用CCTouchTargetedDelegate和CCSprite子类.在定义委托方法时,我无法在函数内部使用"this".

正如先前提到的问题所回答的那样,我无法使用具有使用范围分辨率的函数的类的名称,因为它然后给了我"'ccTouchBegan'的外线定义与'mygames :: DragSprite中的任何声明都不匹配的错误""

我也尝试在.h文件中声明该函数,但似乎没有任何效果.

我的代码如下: -

.h文件

#pragma once
#include "cocos2d.h"




namespace mygames
{

    class DragSprite: public cocos2d::CCSprite, public cocos2d::CCTargetedTouchDelegate
    {
        public:
            DragSprite* createWithFile(const char *pszFileName);
            bool isTouchingOnSprite(cocos2d::CCPoint  touch);
            virtual bool init();
        bool ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
        static inline cocos2d::CCPoint ccpSub(const cocos2d::CCPoint v1, const cocos2d::CCPoint v2);
        private:
            bool isDrag;
            cocos2d::CCPoint whereTouch;
    };
}
Run Code Online (Sandbox Code Playgroud)

.cpp文件

#include "DragSprite.h"


using namespace mygames;


bool DragSprite::init()
{
    if (!CCSprite::init()) {
        return false;
    }

    whereTouch = cocos2d::CCPointZero;
    isDrag = false;

    return true;
}
DragSprite* DragSprite::createWithFile(const …
Run Code Online (Sandbox Code Playgroud)

c++ ios cocos2d-x cocos2d-x-3.0

3
推荐指数
1
解决办法
2万
查看次数

打印获取MAC地址函数的std :: string时出现意外输出?

使用VC++,当我获得本地系统的MAC地址时,它给我一个十六进制代码.我需要将它转换为std :: string,以便我可以在我的代码中使用它.但我无法正常使用它.我知道我必须错过关于c ++中字符串的一个非常基本的概念,请在这里帮助我.

这是我的COED: -

void getMACAddr()
{
CCLOG("getMACAddr 1");
IP_ADAPTER_INFO *info = NULL, *pos;
DWORD size = 0;

GetAdaptersInfo(info, &size);

info = (IP_ADAPTER_INFO *)malloc(size);

GetAdaptersInfo(info, &size);
CCLOG("getMACAddr 2");

for (pos = info; pos != NULL; pos = pos->Next) 
{
    std::stringstream ss;
    CCLOG("getMACAddr 3");
    CCLOG("\n%s\n\t", pos->Description);
    CCLOG("HEX = :%2.2x", pos->Address[0]);
    ss << pos->Address[0];
    for (int i = 1; i < pos->AddressLength; i++)
    {
        CCLOG("HEX = :%2.2x", pos->Address[i]);
        ss << pos->Address[i];
    }
    std::string tS = ss.str();
    CCLOG("%s", tS.c_str());
}
free(info); …
Run Code Online (Sandbox Code Playgroud)

c++ winapi visual-c++

2
推荐指数
1
解决办法
400
查看次数

使用 UIImageJPEGRepresentation() 时无法将 NSData 转换为 NSString?

我正在创建一个多部分图像数据上传请求。我通过 UIImageJPEGRepresentation 从 UIImage 获取 NSData 但是当我尝试将数据转换为字符串时我得到 nil 值

我已按照此链接将 NSData 转换为 NSString

将 UTF-8 编码的 NSData 转换为 NSString

这是我的代码:-

    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
    [request addValue:contentType forHTTPHeaderField:@"Content-Type"];
    NSMutableString *body = [NSMutableString string];
    [body appendFormat:@"--%@\r\n", boundary];
    int i =0;
    for (UIImage *image in imagesArray) {
        NSData *data = UIImageJPEGRepresentation(image, 1.0);
        [body appendFormat:@"Content-Disposition:form-data; name=\"userfile[]\"; filename=\"image%d.jpeg\"\r\n",i];
        [body appendFormat:@"Content-Type: image/*\r\n\r\n"];
        NSString *str = [NSString stringWithUTF8String:[data bytes]]; //this variable should not be nil
        [body appendFormat:@"%@",str];
        if (error)
        {
            NSLog(@"%@", error);
        }
        i++; …
Run Code Online (Sandbox Code Playgroud)

objective-c uiimagejpegrepresentation ios

0
推荐指数
1
解决办法
898
查看次数

openfire邮件档案管理中的服务不可用错误

我正在使用带有openfire 4.2.0的监控插件1.6.0。

以下是openfire管理控制台上存档设置的屏幕截图。

在此处输入图片说明

以下也是我与此配合使用的插件的屏幕截图。 在此处输入图片说明

我的问题

如您所见,该插件已安装。但是,当我尝试使用以下代码获取聊天记录时:我收到服务不可用的响应。

func fetchChatHistoryFromServer(completionHandler completion: @escaping FetchChatHistoryCompletionHandler) {

    let iq = DDXMLElement(name: "iq")
    iq.addAttribute(withName: "type", stringValue: "set")
    iq.addAttribute(withName: "id", stringValue: UserManager.shared.activeUser.jid)

    let query = DDXMLElement(name: "query")
    query.setXmlns("urn:xmpp:mam:2")
    query.addAttribute(withName: "queryid", stringValue: XMPPManager.shared.xmppStream.generateUUID)

    let x = DDXMLElement(name: "x")
    x.setXmlns("jabber:x:data")
    x.addAttribute(withName: "type", stringValue: "submit")


    let field = DDXMLElement(name: "field")
    field.addAttribute(withName: "var", stringValue: "FORM_TYPE")
    field.addAttribute(withName: "type", stringValue: "hidden")
    let fieldValue = DDXMLElement(name: "value", stringValue: "urn:xmpp:mam:2")
    field.addChild(fieldValue)
    x.addChild(field)
    query.addChild(x)
    iq.addChild(query)
    //let xmppResultSet = XMPPResultSet(max: 2000)
    Logger.log(iq)
    didFetchChatHistoryCompletionBlock = completion
    xmppMessageArchivingManagement?.retrieveMessageArchive(withFields: [iq], …
Run Code Online (Sandbox Code Playgroud)

openfire ios xmppframework

0
推荐指数
1
解决办法
293
查看次数

无法理解C中字符串和循环的这种意外行为

这是我的C程序及其输出的屏幕截图,这是一本书中的问题,我遇到过.

在此输入图像描述

你可以看到我的代码中有一个"for"循环.所以我做的是,我改变了循环初始化的值

for(i=6;s1[i]!='\0';i++);
Run Code Online (Sandbox Code Playgroud)

现在输出又来了

矩阵大小6

我一次又一次地更改了初始化值,然后按如下方式输出"i"的输出值

初始化|||| OutPut价值(i)

6 - > 6

7 - > 11

8 - > 11

9 - > 11

10 - > 11

11 - > 11

12 - > 20

我的问题

为什么它没有得到我的值i =循环的初始化值,每当我把loop的初始值>输入字符串的大小(即在这种情况下"矩阵")?

因为6之后的所有char-array元素都应该为null,不应该是吗?

c c++ string for-loop char

-1
推荐指数
1
解决办法
184
查看次数