小编Cai*_*uza的帖子

裁剪UIImage以适合帧图像

我需要裁剪一个UIImage,用设备相机拍摄,以便它适合另一个UIImage,它代表一个frame(带有圆形边框等).检查下图:

在此输入图像描述 使用Aspect Fill

在此输入图像描述 使用Aspect Fit

所以,我需要的是删除超出帧边界的图像多余.我尝试使用UIBezierPath,CGImageRef而我Google其他方法,但是我没有找到一个解决方案.

iphone objective-c uiimage ios

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

格式来自本地化字符串的字符串

我有这个函数来显示带有参数的本地化文本:

func displayLocalizedMessage(key: String, args: [CVarArg]) {
    someLabel.text = String.localizedStringWithFormat(NSLocalizedString(key, comment: ""), args)
}
Run Code Online (Sandbox Code Playgroud)

如果我调用它传递两个参数,例如notificationPostTaggingaskey["Joshua"]for args,本地化字符串如下所示:

"notificationPostTagging" = "%@ tagged you in a post.";

我在应用程序中打印了这个:

(
  Joshua
) tagged you in a post.
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题。我无法将第二个参数作为逗号分隔列表传递,因为它来自其他一些对象。

谢谢

ios swift

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

UIButton无法点击

我在其他帖子中搜索过但我找不到解决方案.

我有一个无法点击的UIButton.当我点击时,它不会变暗.问题不在于选择器方法.

有人能帮我吗?!这是代码:

- (void)drawRect:(CGRect)rect
{

    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 436)];

    UIView *detailsView = [[UIView alloc] init];

// I have other components here and after the UIButton

    UIButton *btnOpenPDF = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnOpenPDF setBackgroundImage:[UIImage imageNamed:@"btnVisualizarPdf"] forState:UIControlStateNormal];
    [btnOpenPDF setFrame:CGRectMake(35, totalHeight, 249, 30)];
    btnOpenPDF.userInteractionEnabled = YES;
    [btnOpenPDF addTarget:self action:@selector(openPdf:) forControlEvents:UIControlEventTouchDown];

    [detailsView addSubview:btnOpenPDF];

    [scroll addSubview:detailsView];

    [self addSubview:scroll];

}
Run Code Online (Sandbox Code Playgroud)

上面的代码在UIView中,通过方法-loadView()通过UIViewController调用.

下面是openPdf的方法:

- (IBAction)openPdf:(id)sender{
// Creates an instance of a UIWebView
    UIWebView *aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320,450)];

// Sets …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uibutton ios

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

限制数组字段的查询结果

是否可以限制我在数组字段中获得的结果数量?我有这样的架构:

{
    timestamp: Number,
    users: [{ name: String, age: Number }]
}
Run Code Online (Sandbox Code Playgroud)

我正在使用猫鼬,我需要users在此示例中限制字段的结果.

有可能吗?我没有找到任何东西,只是limit文件.

mongoose mongodb node.js

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

按data-name属性查找div

是否可以找到<div>具有某些特定" data-name"属性值的?

例如:我需要找到<div data-name="place">动态包含一些代码.

jquery

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

IF子句是不是验证NSString函数返回?

我有下面的函数验证另一个函数的返回(函数searchPlaces返回NSString).当我运行它时,似乎没有调用if子句,因为NSLog(@"函数返回:%@",nova url); 出现在控制台中.

有人能告诉我代码中是否有错误?(肯定有错!)

- (void) buttonPushRandomViewController1 {

    UIViewController *randomViewController = [self randomViewController3];

    NSString *novaurl = [self searchPlaces];
    NSLog(@"Function Return: %@",novaurl);

    if (novaurl == @"OK") {
        randomViewController.title = @"Resultado";
        [self.master pushViewController:randomViewController animated:YES];

        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:novaurl]];
        [webView loadRequest:request];
    }else if (novaurl == @"ZERO_RESULTS") {
        UIAlertView *zeroResults = [[UIAlertView alloc] initWithTitle: @"Ops!" message: @"Sorry, nothing found!" 
                                                             delegate: self cancelButtonTitle: @"OK" otherButtonTitles: nil];
        [zeroResults show];
        [zeroResults release];
    }
}
Run Code Online (Sandbox Code Playgroud)

提前致谢!

objective-c ios

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