小编Rei*_*ica的帖子

用Swift初始化UIViewController的子类?

我试图了解如何使用UIViewController的子类在Swift中进行初始化.我认为基本格式是这样的,但是它会抛出错误......

init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!)   {
    //other code
    super.init(nibName: String?, bundle: NSBundle?)
}
Run Code Online (Sandbox Code Playgroud)

ios swift ios8

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

UIButton click crashing没有实现methodSignatureForSelector: - 提前遇到问题无法识别的选择器

在按下按钮的Swift中,应用程序崩溃并出错

没有实现methodSignatureForSelector: - 麻烦提前无法识别的选择器

在代码中,我的Controller类获取对UIButton的引用,并添加如下所示的目标

aButton.addTarget(self, action: "pressed:", forControlEvents: UIControlEvents.TouchUpInside)
Run Code Online (Sandbox Code Playgroud)

按下的功能定义为

func pressed(sender:UIButton)
{
   println("button pressed")
}
Run Code Online (Sandbox Code Playgroud)

控制器类定义为

class MyController
{
 init()
{
}
// Also here it gets the reference to the UIButton and has pressed function as well.
}
Run Code Online (Sandbox Code Playgroud)

ios swift

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

应用程序崩溃与EXC_BREAKPOINT错误

我有一个我在Xcode 7.2中制作的应用程序.我有一个主菜单,其中一个按钮有一个设置视图控制器的segue.设置视图控制器具有以下代码,每次到达该视图控制器时,它都会因EXC_BREAKPOINT错误而崩溃.有趣的是,这只发生在运行iOS 7的iPhone 4上.它不会在运行iOS 9的iOS模拟器iPhone 6中崩溃.

无论如何,这是代码.

//
//  SettingsController.swift
//  Arbor Hills iOS
//
//  Created by Andrew on 11/22/15.
//  Copyright © 2015 Arbor Hills Vet. All rights reserved.
//

import UIKit

class SettingsController: UITableViewController {

    @IBOutlet weak var username: UITextField!
    @IBOutlet weak var password: UITextField!
    @IBOutlet weak var notifications: UISwitch!
    override func viewDidLoad(){
        super.viewDidLoad()

        let defaults = NSUserDefaults.standardUserDefaults()
        let dusername = defaults.valueForKey("username")!

        let dpassword = defaults.valueForKey("password")!
        let dnotifications = defaults.valueForKey("notifications")!

        username!.text = String(dusername)
        password!.text = String(dpassword)
        if(dnotifications …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios swift

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

Facebook应用程序.Iphone应用商店ID无效

我正在建立一个Facebook应用程序.它需要iPhone应用程序商店ID.在我的itunesConnect中,我已经设置了应用程序并且它给了我AppID,一个数字编号.该应用尚未上市.我把这个号码放在我的Facebook应用程序设置中,但它给了我一个错误,说我们无法从应用程序商店获取应用程序.我哪里错了?

iphone sdk facebook ios

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

是否可以分配热键在Android Studio中的Activity和XML布局之间切换?

当活动打开时,Android Studio会在左上角显示此按钮,单击时会跳转到相应的活动布局:

在此输入图像描述

是否可以为此按钮分配热键?我查看了首选项中的键盘映射页面,但找不到此按钮的任何内容.

android android-studio

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

如何返回pdf对象而不是使用fpdf保存

我需要创建一个pdf文件,并通过POST请求发送到服务器。对于创建pdf,代码非常简单

require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output("mypdf.pdf");
Run Code Online (Sandbox Code Playgroud)

对于POST,我通过以下方式阅读pdf文件:

$file_contents = file_get_contents("mypdf.pdf");
Run Code Online (Sandbox Code Playgroud)

有没有一种方法我不必先写文件然后从文件中读回?一些做事的方式

$file_contents = $pdf->Output();
Run Code Online (Sandbox Code Playgroud)

php pdf fpdf

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

使用openCV for iOS拼接图像的问题

我正在尝试从这里采用代码:

https://github.com/foundry/OpenCVStitch

进入我的计划.但是,我碰壁了.此代码将已存在的图像拼接在一起.我正在尝试制作的程序会将用户拍摄的图像拼接在一起.我得到的错误是,当我将图像传递给针脚功能时,它说它们的大小无效(0 x 0).

这是拼接功能:

- (IBAction)stitchImages:(UIButton *)sender {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{


        NSArray* imageArray = [NSArray arrayWithObjects:
                               chosenImage, chosenImage2, nil];
        UIImage* stitchedImage = [CVWrapper processWithArray:imageArray]; // error occurring within processWithArray function
        dispatch_async(dispatch_get_main_queue(), ^{

            NSLog (@"stitchedImage %@",stitchedImage);
            UIImageView *imageView = [[UIImageView alloc] initWithImage:stitchedImage];
            self.imageView = imageView;
            [self.scrollView addSubview:imageView];
            self.scrollView.backgroundColor = [UIColor blackColor];
            self.scrollView.contentSize = self.imageView.bounds.size;
            self.scrollView.maximumZoomScale = 4.0;
            self.scrollView.minimumZoomScale = 0.5;
            self.scrollView.contentOffset = CGPointMake(-(self.scrollView.bounds.size.width-self.imageView.bounds.size.width)/2, -(self.scrollView.bounds.size.height-self.imageView.bounds.size.height)/2);
            [self.spinner stopAnimating];

        });


    });

}
Run Code Online (Sandbox Code Playgroud)

chosenImage和chosenImage2是用户使用这两个函数拍摄的图像:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    savedImage = info[UIImagePickerControllerOriginalImage]; …
Run Code Online (Sandbox Code Playgroud)

c c++ opencv image ios

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

如何在Spotfire中显示前10列值

我需要使用Spotfire显示前10个值.我google了很多,但我找不到最好的解决方案.

我遵循了本教程:创建动态十大图表,但没有找到成功.

我怎样才能做到这一点?

tibco spotfire

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

如何在iOS应用程序的什么应用程序上分享链接和短信?

我试图从我的iOS应用程序发送短信应用程序的短信,但它没有成功.我在下面添加了我的代码,请告诉我我做错了什么.我的设备安装了什么应用,但我仍然无法发送任何短信.

- (IBAction)whatAppInvite:(id)sender
    {
        NSString * strTextPost = [@"" stringByAppendingFormat:@"Hey try this app. Its amazing. \n\n https://itunes.apple.com/us/app/google-search/*********2?mt=8"];


        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@":" withString:@"%3A"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@"/" withString:@"%2F"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@"?" withString:@"%3F"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@"," withString:@"%2C"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@"=" withString:@"%3D"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@"&" withString:@"%26"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@"." withString:@"%2E"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@"'" withString:@"%27"];
        strTextPost = [strTextPost stringByReplacingOccurrencesOfString:@"-" withString:@"%2D"];

        NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",strTextPost];

        NSURL * whatsappURL = [NSURL URLWithString:urlWhats]; …
Run Code Online (Sandbox Code Playgroud)

objective-c ios whatsapp

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

Objective-C如何使用AFNetworking发布表单数据?

我有一个Web服务,我可以通过Postman实用程序成功发布调用.在Postman上的设置是邮差设置

我无法使用代码使用Afnetworking进行相同的调用.

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"body": @{@"email":@"email@gmail.com",@"name":@"myName"}};
[manager POST:@"http://myURL.com/user" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];
Run Code Online (Sandbox Code Playgroud)

我的猜测是我没有正确设置表单数据?

ios afnetworking afnetworking-2

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

SQLiteException:near"=":语法错误(代码1):(已关闭)

应用程序每次运行时都会关闭.当我检查logcat时,这是继续弹出的错误.

android.database.sqlite.SQLiteException: near "=": syntax error (code 1): , while compiling: SELECT * FROM tblresultsWHEREtopid=1ANDusname=fbbh
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
        at android.app.ActivityThread.access$600(ActivityThread.java:165)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:194)
        at android.app.ActivityThread.main(ActivityThread.java:5391)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
        at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

这是来自DBHELPER的我的片段:TOP_ID初始化为字符串.

public List<Result> getAllResult() {


    String qry3 = "SELECT * FROM " + TABLE_RESULT + "WHERE" + TOP_ID + "=" + "1" + "AND" + USER_NAME + "=" + user;

    Log.e(LOG, qry3);

    SQLiteDatabase db = this.getReadableDatabase();

    Cursor c = …
Run Code Online (Sandbox Code Playgroud)

sqlite android

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

Swift - 不同表视图单元格的通用模型

我正在开发一个表格视图(类似于 Facebook Messenger 的表格视图),其中有不同的单元格类型(图像、文本、视频等)。我想要存档的是,我想声明一个列表message model,我将配置tableView,以便单元格将由模型本身确定和配置。为了做到这一点,我需要以某种方式告诉它关联的是model哪个UITableViewCell类。基本上我想要一个像这样的协议:

protocol ChatMessageDisplayable {
   static var myCellType: UITableViewCell { get } //Defines the UITableViewCell class this model is associated with
   func configure(cell: /*the associated cell type*/) // Let the model itself configure the cell.
}
Run Code Online (Sandbox Code Playgroud)

然后我在我的 ViewController 中声明一个数组

messageModels = [ChatMessageDisplayable]

我的 UITableViewDataSource 实现:

public func numberOfSections(in tableView: UITableView) -> Int {
    return messageModels.count
}

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let model …
Run Code Online (Sandbox Code Playgroud)

generics uitableview swift

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