小编Stu*_*ner的帖子

如何停止核心动画?

我正在动画一个按钮使用核心动画现在在某种情况下,我想停止该动画我如何停止动画?

这是为按钮设置动画的方法

-(void)animateButton:(UIButton *)btnName
{
    CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    pulseAnimation.duration = .5;
    pulseAnimation.toValue = [NSNumber numberWithFloat:1.1];
    pulseAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    pulseAnimation.autoreverses = YES;
    pulseAnimation.repeatCount = FLT_MAX;

    [btnName.layer addAnimation:pulseAnimation forKey:nil];
}
Run Code Online (Sandbox Code Playgroud)

xcode core-animation objective-c iphone-sdk-3.0

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

如何在下载时在UIImageView中显示渐进式JPEG?

从网上下载图像并在UIImageView中显示它是相当容易的.但是,这需要在向用户显示图像之前完全下载图像,从而完全击败渐进式JPEG(和PNG)图像.

如何在传输过程中渲染部分下载的图像?我会想象SDK有一些回调函数可以更新图像,但我找不到这样的功能.使用当前的iOS SDK是否可行?

png jpeg progressive-download uiimageview ios

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

使用NSDataDetector检查电子邮件

我有一个来自服务器的字符串,想检查它是否包含电话号码,邮件地址和电子邮件等表达式.我在电话号码和邮件地址方面取得了成功,但没有收到电子邮件.我是NSDataDetector为了这个目的而使用的.例如

NSString *string = sourceNode.label; //coming from server

//Phone number
NSDataDetector *phoneDetector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypePhoneNumber error:nil]; 
NSArray *phoneMatches = [phoneDetector matchesInString:string options:0 range:NSMakeRange(0, [string length])];

for (NSTextCheckingResult *match in phoneMatches) {

    if ([match resultType] == NSTextCheckingTypePhoneNumber) {
        NSString *matchingStringPhone = [match description];
        NSLog(@"found URL: %@", matchingStringPhone);
    }
}  
Run Code Online (Sandbox Code Playgroud)

但是如何为电子邮件做同样的事情呢?

iphone ios nsdatadetector

7
推荐指数
4
解决办法
6637
查看次数

Obj-C中的id和Delegate用法

我想知道下面的代码行是做什么的:

@property (assign, nonatomic) id <CoursePlannerDelegate> delegate;
Run Code Online (Sandbox Code Playgroud)

也就是说,我想知道这部分线路:

id <CoursePlannerDelegate> delegate;
Run Code Online (Sandbox Code Playgroud)

它也出现在其他地方:

@interface CategoryAddViewController : UIViewController {

 UITextField *nameField, *weightField;
 double maxWeight; //The maximum weight that can be allocated to this Category (max value of 100)
 id <CategoryAddDelegate> delegate; //A Course Planner TVC

}
Run Code Online (Sandbox Code Playgroud)

delegates objective-c ios

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

如何在Selenium中导航到新网页?

我有以下代码:

driver.get(<some url>)
for element in driver.find_elements_by_class_name('thumbnail'):
    element.find_element_by_xpath(".//a").click() #this works and navigates to new page
    element.find_element_by_link_text('Click here').click() #this doesn't
Run Code Online (Sandbox Code Playgroud)

需要通过单击指向新页面的缩略图来导航以下HTML(当然简化),然后需要单击该Click here新页面中的链接:

<!DOCTYPE html>
<html lang="en-US" prefix="og: http://iuytp.me/ns# fb: http://iuytp.me/ns/fb#">
<head>
<meta charset="UTF-8" />
<title>Releases</title>
</head>

<body class="archive category category-releases category-4 custom-background">
    <div id="main">
        <div id="container" class="one-column">
            <div id="content" role="main">

                <h1 class="page-title">Releases</h1>

            <div id="thumbnail-post-display">
        <div id="thumbnail-post" class="post-7158 post type-post status-publish format-standard has-post-thumbnail hentry category-blog category-designer category-releases category-uncategorized">
            <div class="thumbnail"><a href="http://records.net/uncategorized/designer-7-inch-bufu-records-co-release/" title="Permanent link to Designer &#8211; 7 inch" rel="bookmark"><img width="300" …
Run Code Online (Sandbox Code Playgroud)

selenium python-2.7

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

将MKPolygon作为叠加层添加到MKMapView时出现问题

Ey那里,正如标题所说,我很难将MKPolygon添加为MKMapView的叠加层.以下是相关代码:
ParkingMapViewContoller.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>


@interface ParkingMapViewController : UIViewController <MKMapViewDelegate> {
    MKMapView *mapView;
}

@property (nonatomic, retain) IBOutlet MKMapView *mapView;


-(void)loadAnnotations;
-(void)showCurrentLocationButtonTapped:(id)sender;


@end
Run Code Online (Sandbox Code Playgroud)

ParkingMapViewController.m

//...
#import "ParkingRegionOverlay.h"
//...
- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"%@",self.title);

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:100 target:self action:@selector(showCurrentLocationButtonTapped:)];

    /*MKMapPoint points[3] = {{38.53607,-121.765793}, {38.537606,-121.768379}, {38.53487,-121.770578}};
    MKPolygon *polygon = [MKPolygon polygonWithPoints:points count:3];*/

    ParkingRegionOverlay *polygon = [[ParkingRegionOverlay alloc] initialize];
    [mapView addOverlay:polygon];

    [self loadAnnotations];

    CLLocationCoordinate2D centerCoord = { UCD_LATITUDE, UCD_LONGITUDE };
    [mapView setCenterCoordinate:centerCoord zoomLevel:13 animated:NO]; //from "MKMapView+ZoomLevel.h"
}
//...

- …
Run Code Online (Sandbox Code Playgroud)

iphone overlay mkmapview ios

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

以编程方式将项添加到UIToolbar不起作用

我最近一直在询问有关UIToolbars的问题,但是现在我发现我需要以编程方式添加项目,我已经看到了其他人如何去做的方法,但是当我尝试做同样的事情时,没有什么最终出现.找出这个问题是我需要帮助的.以下是我在IB的关系:

替代文字

以下是相关代码:

头文件:

#import <UIKit/UIKit.h>

@interface ParkingRootViewController : UIViewController {
    UINavigationController *navigationController;
    UIToolbar *toolbar;
    UIBarButtonItem *lastUpdateLabel;
}

@property(nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet UIToolbar *toolbar;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *lastUpdateLabel;

- (IBAction)selectHome:(id)sender;

@end
Run Code Online (Sandbox Code Playgroud)

实施文件:

- (void)viewDidLoad {
        [super viewDidLoad];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 150.0f, 20.0f)];
    label.text = @"last updated...";
    label.textColor = [UIColor colorWithWhite:1.0 alpha:1.0];
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = UITextAlignmentCenter;
    label.font = [UIFont boldSystemFontOfSize:13.0];
    label.userInteractionEnabled = NO;

    lastUpdateLabel = [[UIBarButtonItem alloc] initWithCustomView:label]; …
Run Code Online (Sandbox Code Playgroud)

uitoolbar uibarbuttonitem ios4 ios

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

iOS模拟器中是否有相机设备模拟?

Android模拟器可以模拟Camera设备(请参见屏幕截图),例如,我可以测试视频录制模块的工作方式:

Android Emulator,相机仿真示例

那iOS模拟器呢?当我尝试运行使用相机的应用时,出现下一个错误

Thread 5: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Run Code Online (Sandbox Code Playgroud)

在线

let videoDeviceInput = try AVCaptureDeviceInput(device: defaultVideoDevice!)
Run Code Online (Sandbox Code Playgroud)

所以没有模拟设备可用于iOS模拟器?

xcode ios ios-simulator

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

将UISegmentedControlNoSegment指定为UISegmentedControl的selectedSegmentIndex不会对iOS 13产生影响

我是STAControls的维护者,该类继承了各种UIControls,其中一个是UISegmentedControl。在该项目的示例应用程序中,我具有以下代码(可以从上述链接下载):

- (void)textFieldDidEndEditing:(UITextField *)textField {
    NSInteger integer = [textField.text integerValue];
    if (integer < 0 || integer >= self.segmentedControl.numberOfSegments) { this doesn't work
        self.segmentedControl.selectedSegmentIndex = UISegmentedControlNoSegment;
    } else { // this works
        self.segmentedControl.selectedSegmentIndex = integer;
    }
}
Run Code Online (Sandbox Code Playgroud)

在iOS 13中,UISegmentedControlNoSegment不遵循分配:

在此处输入图片说明

在iOS 12和iOS的早期版本中,此功能可以正常运行:

在此处输入图片说明

有关如何解决此问题的任何想法?

objective-c uisegmentedcontrol ios13

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

isKindOfClass不能像预期的那样工作IOS 7

下面的代码在IOS 5.0,6.0,6.1等上返回"YES",但在IOS 7.0上返回"NO".窦你对此有所了解吗?这是IOS 7.0的错误吗?非常感谢..

[view isKindOfClass:[SimpleLabel class]]
Run Code Online (Sandbox Code Playgroud)

PS:"SimpleLabel"是一个继承自UILabel的类.

---- ----更新

对不起,问题不明确.:(我在UITableViewCell上课时使用上面的代码,并添加SimpleLabel如下;

 [self addSubview:label];
Run Code Online (Sandbox Code Playgroud)

我重写layoutSubviews函数,循环self.subviews,但[view class]总是返回UITableViewCellScrollView.

-(void)layoutSubviews {
[super layoutSubviews];
for (UIView*view in self.subviews) {
    if ([view isKindOfClass:[SimpleLabel class]]) {
        SimpleLabel*label = (SimpleLabel*)view;
Run Code Online (Sandbox Code Playgroud)

objective-c ios ios7

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