我有一个问题:-(当我构建我的应用程序以释放XCode时显示警告说:
iPhone apps with a deployment target lower than 4.3 should include an armv6 architecture (current IPHONEOS_DEPLOYMENT_TARGET = "3.0", ARCHS = "armv7").
Run Code Online (Sandbox Code Playgroud)
但是如何设置armv6
我的构建设置?我正在使用XCode 4.2
,这是我的构建设置:
谢谢!
如何IBAction
通过按一下来播放声音并UIbutton
再次按下按钮暂停它AVAudioPlayer
?此外,我想改变UIButton
播放声音时的状态,以及声音播放时的状态.
这是我的代码:
- (IBAction)Beat
{
if ([Media2 isPlaying])
{
[Media2 pause];
[Button17 setSelected:NO];
}
else
{
Path = [[NSBundle mainBundle] pathForResource:@"Beat" ofType:@"mp3"];
AVAudioPlayer *Media2 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:Path] error:NULL];
[Media2 setDelegate:self];
[Media2 play];
[Button17 setSelected:YES];
}
}
Run Code Online (Sandbox Code Playgroud) 基于我在Apple Swift 网站上找到的一个例子,我给自己做了一个练习Swift的练习:
正如你所看到的那样,中间有一条河流和几个圆点,形成一条小路.所以我开始在互联网上寻找类似的河流图像,我已经创建了一个Xcode游乐场.这就是我现在拥有的:
所以基本上我有UIView
一个子视图,包含我找到的河图像和一个点UIBezierPath
.
我的第一个问题是:这是吸引UIView的正确方法吗?我的意思是使用UIBezierPath
.我的第二个问题是:如何在内部的精确坐标处绘制点UIView
?(UIBezierPath
或其他一切?)
更确切地说,我的目的是制作一个算法,使程序识别图像,并根据像素颜色,它将绘制一条从河的起点到终点的点线,在它的中间穿过.
我想知道如何使用UIImagePickerController打开iPhone 4上的相机闪光灯.
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerCameraDeviceFront] == YES)
{
/// What code here ///
}
else
{
NoFlash = [[UIAlertView alloc] initWithTitle:@"Uh-Oh"
message:@"Your device doesn't have a flash camera"
delegate:nil
cancelButtonTitle:@"mhmm, OK"
otherButtonTitles:nil];
NoFlash.delegate = self;
[NoFlash show];
[NoFlash release];
}
Run Code Online (Sandbox Code Playgroud)
}
我已经在这里阅读了UIImagePickerController类参考网页:http://bit.ly/cdAhhB但我找不到答案.有人可以帮帮我吗?
谢谢
我正在尝试使用Apple App Thinning功能(可从iOS 9获得),该功能可让您根据设备架构和功能来区分资源。就我而言,我想做的是在应用程序捆绑包中使用.mp4
格式(在格式中)另存一个视频文件,其中一个用于iPhone,另一个用于使用Xcode的iPad .xcassets
Data Set
。
从.xcassets
Data Set
Apple 检索文件提供了NSDataAsset
该类,但是:由于AVPlayer
需要URL
播放视频,并且NSDataAsset
仅使用Data
格式提供其内容,因此无法播放视频。
我想做的就是找回NSDataAsset
.data
URL
。可能吗?
我知道,这是一个奇怪的问题^^,
我想知道是否有办法在UIStatusBar中(或上)写一些文本.特别是当用户按下UIButton时,我想在状态栏上写一些文本.
谢谢!
我遇到了问题CGFloat
.我想要做的是设置一个X的值,UIScrollView
以便在用户使用a UIButton
来做更改页面时执行某些操作.
这是Xcode给我的错误:
Incompatible integer to pointer conversion assigning to 'CGFloat *' (aka 'float *') from 'int'
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
.H
#import <UIKit/UIKit.h>
@interface MenuViewController : UIViewController <UIScrollViewDelegate>
{
}
@property (nonatomic) CGFloat *offsetPoint;
@property (weak, nonatomic) IBOutlet UIScrollView *trackSelectionScrollView;
@end
Run Code Online (Sandbox Code Playgroud)
.M
- (void)scrollForward
{
self.offsetPoint = self.trackSelectionScrollView.contentOffset.x; // Error here
if ((self.offsetPoint = 0)) // Error here
{
[self.trackSelectionScrollView setContentOffset:CGPointMake(320, 0) animated:YES];
}
if ((self.offsetPoint = 320)) // Error here
{
[self.trackSelectionScrollView setContentOffset:CGPointMake(640, 0) animated:YES];
} …
Run Code Online (Sandbox Code Playgroud) 我在UITextField
使用新Swift
语言创建前缀时遇到了问题.目前我已经创建了UITextField
使用Interface Builder并且已经分配了一个IBOutlet
名为usernameField的textFieldDidBeginEditing
函数,然后使用我NSMutableAttributedString
在其中编写的函数,名为usernamePrefix,仅包含单词"C-TAD-",最后我限制了UITextField
最大字符数字为13,如下:
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet var usernameField : UITextField!
private var usernamePrefix = NSMutableAttributedString(string: "C-TAD-")
func textFieldDidBeginEditing(textField: UITextField) {
if textField == usernameField {
if usernameField.text == "" {
usernameField.attributedText = usernamePrefix
}
}
usernameField.addTarget(self, action: "textFieldDidChangeText:", forControlEvents:UIControlEvents.EditingChanged)
}
func textField(textField: UITextField!, shouldChangeCharactersInRange range: NSRange, replacementString string: String!) -> Bool {
let maxUsernameLength = countElements(usernameField.text!) + countElements(string!) - range.length …
Run Code Online (Sandbox Code Playgroud) 我在开发 iOS 应用程序时遇到一个问题,我想要实现的是从字符串数组创建单个字符串。该数组包含给定位置的地址,该地址是使用 的反向地理编码获得的CLGeocoder
,这是为我提供字符串数组的代码:
let userCoordinates = CLLocation(latitude: mapView.userLocation.location!.coordinate.latitude, longitude: mapView.userLocation.location!.coordinate.longitude)
CLGeocoder().reverseGeocodeLocation(userCoordinates, completionHandler: {
placemark, error in
let reverseGeocodedLocation = placemark?.first?.addressDictionary?["FormattedAddressLines"] as? [String]
}
Run Code Online (Sandbox Code Playgroud)
reverseGeocodedLocation
就我而言是:
["Apple Inc.", "Cupertino, CA 95014", "United States"]
Run Code Online (Sandbox Code Playgroud)
结果字符串应分隔数组中的字符串,并以多行格式呈现它们,如下所示:
Apple Inc.
Cupertino, CA 95014
United States
Run Code Online (Sandbox Code Playgroud)
我尝试在网上搜索解决方案,我发现这段代码应该可以做到这一点,这可能是解决方案:
print("\n".join(reverseGeocodedLocation.map({$0})))
Run Code Online (Sandbox Code Playgroud)
但编译器说:
无法使用“([String]?)”类型的参数列表调用“join”
我想知道如何在我的应用程序首次启动时显示UIAlertView或UIView.
谢谢.
我有一个GCD
背景.我有一个按钮,按下时我希望它在GCD完成时加载一个加载等待屏幕,然后执行该按钮上的其余代码.随附的是样本.
我无法工作,我基本上想说,只要完成GCD需要等待,并在此期间加载等待消息,完成后继续编码.
谢谢
- (IBAction)btnTapped:(id)sender
{
shouldCancel=NO;
dispatch_queue_t existingQueque = dispatch_get_main_queue();//finds the current GCD, the one I created in a different method
dispatch_group_t group =dispatch_group_create();
dispatch_group_async(group, existingQueque, ^
{
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);//does not work, I guess group can't be created here.
[self performSelectorOnMainThread:@selector(showWaitViewWithMessage:) withObject:@"Loading" waitUntilDone:YES];//load this until GCD queque done
[self performSelector:@selector(performSearch) withObject:nil afterDelay:0];
});
}
Run Code Online (Sandbox Code Playgroud) 你能告诉我以下代码是否100%正确吗?特别是该dealloc
部分
FirstViewController.h
#import <UIKit/UIKit.h>
#import "SecondViewController.h"
@class SecondViewController
@interface FirstViewController : UIViewController
{
SecondViewController *SecondController;
}
- (IBAction)SwitchView;
@property (nonatomic, retain) IBOutlet SecondViewController *SecondController;
@end
Run Code Online (Sandbox Code Playgroud)
FirstViewController.m
#import "FirstViewController.h"
@implementation FirstViewController
@synthesize SecondController;
- (IBAction)SwitchView
{
SecondController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
SecondController.modalTransitionStyle = UIModalPresentationFullScreen;
[self presentModalViewController:SecondController animated:YES];
[SecondController release];
}
/// OTHER CODE HERE ///
- (void)dealloc
{
[SecondController release];
[super dealloc];
}
@end
Run Code Online (Sandbox Code Playgroud)
谢谢!
我想UISwitch
在a accessoryView
中放置一个UITableViewCell
,问题是如果我尝试将它放在cellForRowAtIndexPath
func中它正常工作并且UISwitch正确创建并显示在UITableViewCell的右侧,而不是我在外面创建它功能它将无法正常工作.我需要在有趣的地方创建它,因为我需要在其他函数中检查UISwitch的状态并相应地执行代码.
我更好地解释了我对" 外部 "的意思:Objective-C
你可以@property(ies)
让你从当前类文件中的任何地方访问对象,我们可以实现同样的目的Swift
吗?
这是我的代码:
import UIKit
class ConfigurationViewController: UITableViewController, UITextFieldDelegate {
weak var useAuthenticationSwitch: UISwitch!
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as! UITableViewCell
if indexPath.section == 0 {
if indexPath.row == 0 {
cell.textLabel!.text = "Use Authentication"
cell.accessoryView = useAuthenticationSwitch
}
} else {
}
return cell
}
}
Run Code Online (Sandbox Code Playgroud)
如果,而不是:
cell.accessoryView = useAuthenticationSwitch
Run Code Online (Sandbox Code Playgroud)
我用:
cell.accessoryView …
Run Code Online (Sandbox Code Playgroud) ios ×9
iphone ×5
objective-c ×4
swift ×4
xcode ×3
app-thinning ×1
arrays ×1
camera ×1
cgfloat ×1
cocoa-touch ×1
drawing ×1
pointers ×1
string ×1
uialertview ×1
uiscrollview ×1
uistatusbar ×1
uiswitch ×1
uitableview ×1
uitextfield ×1
uiview ×1
warnings ×1
xcode4 ×1