我从UITextfield获取值到NSString,需要将NSString的值转换为CGPoint,假设如果我在文本字段中输入6,5它应该将其转换为CGPoint.
我有一个简单的查询,我需要强调UIButton文本和颜色.我有uibutton的下线文字,但是关于色调,它不起作用.我已经从xib中设置了色调,它没有从那里开始.下面是我的代码.
NSMutableAttributedString *commentString = [[NSMutableAttributedString alloc] initWithString:@"Testing"];
[commentString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [commentString length])];
[_helpWithLoginLabel setAttributedTitle:commentString forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud) 我正在使用XCode 8 Beta,iOS 10版本中的推送通知.我在设备上收到了推送通知.当我点击通知时,它触发了UNUserNotificationCenterDelegate的委托,app被打开,但它没有在userinfo中显示任何响应.我是否需要在服务器端更改iOS 10中发送推送的参数.以下是我的代码.
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:settings];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (!error) {
NSLog(@"request authorization succeeded!");
}
}];
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
NSLog(@"Notification is triggered");
completionHandler(UNNotificationPresentationOptionAlert);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler {
NSLog(@"Tapped in notification");
NSLog(@"%@",response.notification);
NSString *actionIdentifier = response.actionIdentifier;
if ([actionIdentifier isEqualToString:@"com.apple.UNNotificationDefaultActionIdentifier"] ||
[actionIdentifier …Run Code Online (Sandbox Code Playgroud) 我正在制作一个iPhone应用程序,我需要在UIScrollView中显示一些图像,左右两侧将有两个按钮,用户可以点击按钮,它将显示下一个或上一个图像.同样在底部有一个按钮,当用户点击该按钮时,它将显示我们在scrollview中选择的图像.我想知道如何在滚动视图内显示多个图像,同时选择底部按钮,如何在scrollview中找到哪个图像.
我试图在XCode 9 Beta版本中打开我现有的项目.代码是编译没有任何错误,但是当应用程序启动时模拟器在警报中显示警告.
请告诉我出了什么问题.
无法更改文件的所有者:///Users/stiga/Library/Developer/CoreSimulator/Devices/2A6099D8-6743-4551-AE73-CE7AFCAEE9FE/data/Library/Caches/com.apple.mobile.installd.staging/temp. opEVCA/TestWifog.app:错误域= MIInstallerErrorDomain代码= 4"无法删除ACL"UserInfo = {NSUnderlyingError = 0x7fdb12706dc0 {错误域= NSPOSIXErrorDomain代码= 13"权限被拒绝"UserInfo = {SourceFileLine = 392,NSLocalizedDescription = open of/Users /stiga/Library/Developer/CoreSimulator/Devices/2A6099D8-6743-4551-AE73-CE7AFCAEE9FE/data/Library/Caches/com.apple.mobile.installd.staging/temp.opEVCA/TestWifog.app/GoogleSignIn.bundle/ar .lproj/GoogleSignIn.strings失败:权限被拒绝,FunctionName = - [MIFileManager removeACLAtPath:isDir:error:]}},FunctionName = - [MIFileManager removeACLAtPath:isDir:error:],SourceFileLine = 392,NSLocalizedDescription =无法删除ACL}
我有一个小问题.我正在使用Reachability类来测试互联网连接,它运行良好.但是假设如果用户正在使用Wifi,但是他们无法访问互联网,则应该重试几秒钟,然后它应该向用户显示警报以切换蜂窝网络.以下是我的代码.当Wifi打开时,我没有指出网络连接速度慢的地方.
self.internetReachable = [Reachability reachabilityForInternetConnection];
[self.internetReachable startNotifier];
//_hasConnectivity = ([self.internetReachable currentReachabilityStatus] != NotReachable);
if([self.internetReachable currentReachabilityStatus] == NotReachable) {
_hasConnectivity = NO;
}
else if([self.internetReachable currentReachabilityStatus] == ReachableViaWiFi){
_hasConnectivity = YES;
}
else if([self.internetReachable currentReachabilityStatus] == ReachableViaWWAN) {
_hasConnectivity = YES;
}
Run Code Online (Sandbox Code Playgroud) 我正在制作一个应用程序,其中 PageViewController 应该在某个时间间隔内滚动。目前我已经完成了手动滚动。用户可以滚动任何图像,它会起作用。但坚持通过用户触摸实现自动滚动。下面是我的代码。请帮我解决这个问题。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
_pageTitles = @[@"", @"", @"", @""];
_pageImages = @[@"page1.png", @"page2.png", @"page3.png", @"page4.png"];
// Create page view controller
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];
self.pageViewController.dataSource = self;
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
// Change the size of page view controller
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 50);
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
}
- (PageContentViewController …Run Code Online (Sandbox Code Playgroud) 我已经开始学习 Xamarin 并创建了用于从服务器检索数据的小教程。我使用过 NSUrlSession 机制。下面是我的代码。我不确定为什么 NSUrlSession 会显示警告。请帮助我理解和解决这个警告。
警告 CS0618:“NSUrlSession.FromConfiguration(NSUrlSessionConfiguration, NSUrlSessionDelegate, NSOperationQueue)”已过时:“使用带INSUrlSessionDelegate参数的重载”。(CS0618) (SampleApp)
public void getData() {
NSUrl url = new NSUrl("some url");
NSUrlRequest request = new NSUrlRequest(url);
NSUrlSession session = null;
NSUrlSessionConfiguration myConfig = NSUrlSessionConfiguration.DefaultSessionConfiguration;
session = NSUrlSession.FromConfiguration(myConfig, new MySessionDelegate (), new NSOperationQueue ());
NSUrlSessionTask task = session.CreateDataTask(request, (data, response, error) => {
});
task.Resume();
}
public class MySessionDelegate : NSUrlSessionDelegate, INSUrlSessionDelegate
{
}
Run Code Online (Sandbox Code Playgroud) 我刚刚开始使用 RxSwift 并面临一些挑战。我创建了具有多个部分的 tableview,并且能够点击并获取详细信息。但是,如果我尝试删除任何特定单元格,则它不起作用。我不确定我在 RxSwift 中做错了什么。下面是我的代码。
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel<String, User>>(
configureCell: { (_, tv, indexPath, element) in
let cell = tv.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = string
cell.textLabel?.numberOfLines = 0
return cell
},
titleForHeaderInSection: { dataSource, sectionIndex in
return dataSource[sectionIndex].model
}
)
dataSource.canEditRowAtIndexPath = { dataSource, indexPath in
return true
}
viewModel.getUsers()
.bind(to: tableView.rx.items(dataSource: dataSource))
.disposed(by: disposeBag)
tableView.rx
.itemSelected
.map { …Run Code Online (Sandbox Code Playgroud) 我有一个UIView圆形的形状,我需要显示UIView百分比值的边框颜色,如果百分比值是50%,它应该填充UIView的半边框颜色.我已经使用了UIBeizer路径addArcWithCenter但是我没有得到完美的解决方案.请帮帮我
我正在研究RxSwift,并开始创建一些基本的.我添加了新按钮但是rx_tap订阅不适用于按钮操作.以下是我的代码,请让我知道我做错了什么
let button = UIButton(frame: CGRect(x: 10, y: 66, width: 100, height: 21))
button.backgroundColor = UIColor.redColor()
button.setTitle("Login", forState: UIControlState.Normal)
let disposeBag = DisposeBag()
button.rx_tap
.subscribe { [weak self] x in
self!.view.backgroundColor = UIColor.redColor()
}
.addDisposableTo(disposeBag)
self.view.addSubview(button)
Run Code Online (Sandbox Code Playgroud) 我得到了NSString http://maps.apple.com/maps?saddr=41.447910,-74.357881&daddr=719 Old Route 9 North, Wappingers Falls, NY 12590
但是我需要将上面的字符串转换为这个用于在地图中显示位置的字符串
http://maps.apple.com/maps?saddr=41.447910,-74.357881&daddr=719+Old%20Route+9+North%2CWappingers+Falls%2CNY+12590
请告诉我.
我正在处理 URLSession 的网络调整并获取每个请求的详细信息。但是,当我尝试以毫秒为单位计算请求日期的值时,有时计算会显示更高的值。在 swizzling 中,startLoading我们正在获取当前日期,在里面stopLoading我们正在计算毫秒。下面是我的逻辑
let startDate: Date?
override public func startLoading() {
startDate = Date()
}
override public func stopLoading() {
print(fabs(startDate.timeIntervalSinceNow) * 1000)
}
Run Code Online (Sandbox Code Playgroud) ios ×11
iphone ×7
objective-c ×4
swift ×3
rx-swift ×2
sdk ×2
imageview ×1
ios10 ×1
label ×1
networking ×1
nsstring ×1
reachability ×1
scrollview ×1
uibutton ×1
uiview ×1
xamarin ×1
xamarin.ios ×1
xcode ×1