我刚刚在我的项目中放了一个照片选择器,一切正常.唯一的事情是它坚持在我设置代表时给我以下警告 -
Assigning to 'id<UINavigationControllerDelegate,UIImagePickerDelegate>' from incompatible type 'AddTargetViewController *'
Run Code Online (Sandbox Code Playgroud)
我以正常的方式在AddTargetViewController.h中设置了委托 -
@interface AddTargetViewController : UIViewController <UIImagePickerControllerDelegate>
Run Code Online (Sandbox Code Playgroud)
我看不出有什么不对劲 正如我所说,它工作正常,并且所有委托方法都应该按照它们的方式启动.
-(void)takePhoto {
UIImagePickerController *imagePicker = [[[UIImagePickerController alloc] init] autorelease];
imagePicker.delegate = self; // *** warning on this line ***
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
[self presentModalViewController:imagePicker animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
有没有人知道我在MonoTouch中使用的编译器指令,看看我是否在iPhone模拟器中运行?无法在任何地方找到任何信息.
谢谢!
我有一些代码,我的类继承自超类,到目前为止一切都运行良好.每当我尝试使用任何超类变量时,我都会收到错误,说它们是未声明的(首先在此函数中使用).它只发生在我的一个子类中,它看起来与其他子类完全相同.我想知道是否有任何我应该知道的明显内容(对Objective-C来说是新手).基本代码如下 -
@interface mySuperClass : UIViewController {
BOOL myVar;
}
Run Code Online (Sandbox Code Playgroud)
然后 -
@interface mySubClass : mySuperClass {
}
@implementation mySubClass {
-(void)someMethod {
myVar = YES; // error here
}
@end
Run Code Online (Sandbox Code Playgroud)
任何帮助非常感谢 - 如果您需要更多信息,请告诉我们!谢谢.
So, been messing about with SwiftUI & it's all working except that the list resets its scroll position to the top whenever an item is selected. Nothing I do fixes this. Code -
struct FontSettingsView : View {
@ObjectBinding var settings: FontSettings
var body: some View {
NavigationView {
ContentView(settings: settings)
.navigationBarTitle(Text("Font"), displayMode: .inline)
}
}
struct ContentView: View {
@State var settings: FontSettings
var body: some View {
VStack {
HeaderView(settings: $settings)
FontListView(excludedFontNames: settings.excludedFontNames) { fontName in
self.$settings.name.value = …Run Code Online (Sandbox Code Playgroud) 可能非常简单,但我找不到答案 - 如何在运行时(使用MonoTouch)进行检查以确保我在iPhone模拟器中(或不是)?
谢谢
我在SO和其他地方搜索过MvvmCross和Modal,但现有的答案并没有帮助我们.
我们正在使用MonoTouch和MvvmCross开发一个跨平台的应用程序,这似乎是非常强大的组合.但是,我们在导航方面遇到了一些问题,我们正在逐渐破解!目前的问题是 -
该应用程序使用TabBarController运行,每个选项卡都有导航到更高级别 - 这很好.然而,客户端需要其中一个选项卡上的"开始"按钮以显示模态视图(隐藏其他所有内容,尤其是标签栏),然后其具有与UINavigationController相同的工作方式,具有该功能随时弹回tabBarController.
我们设法提出了一个模态视图,但我们仍然坚持从这里加载新视图并弹出.
任何帮助/建议表示赞赏!
这感觉就像讨论在几个Swift迭代之前停止了,但我很好奇,在讨论中,从未建议(或者如果我从未看过它)单例可能只是一个具有纯类函数的类,例如 -
class MySingleton {
private static var someVar: String?
private static var someOtherVar: SomeType?
class func start() {
// etc...
}
class func doSomething() {
// etc...
}
// etc, etc...
}
Run Code Online (Sandbox Code Playgroud)
我们不应该这样做有什么好的理由吗?我什么都想不到.
我们刚刚更改为Twitter api 1.1,现在Tweeting不起作用并返回错误"远程服务器返回错误:(400)错误请求." 关于SO的研究表明它与身份验证有关,但我们正在发送我们刚刚从登录页面获得的accessToken和secret.这一切都适用于api 1.0.代码是 -
public void Tweet(Action<string> response, string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("POST&");
sb.Append(Uri.EscapeDataString(_postUrl));
sb.Append("&");
string oauthNonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
string timeStamp = MakeTimestamp();
var dict = new SortedDictionary<string, string>
{
{ "oauth_consumer_key", _oAuthConfig.ConsumerKey },
{ "oauth_nonce", oauthNonce },
{ "oauth_signature_method", "HMAC-SHA1" },
{ "oauth_timestamp", timeStamp },
{ "oauth_token", _accessToken },
{ "oauth_version", "1.0" },
};
foreach (var keyValuePair in dict)
{
sb.Append(Uri.EscapeDataString(string.Format("{0}={1}&", keyValuePair.Key, keyValuePair.Value)));
}
string encodedMessage = EscapeAdditionalChars(Uri.EscapeDataString(message));
sb.Append(Uri.EscapeDataString("status=" + encodedMessage));
string …Run Code Online (Sandbox Code Playgroud) 我想从ViewModels中获取所有本地化文本(因为它通常是动态的),我想知道如何使用转换器从用于本地化的json文件中获取文本.例如,在下面的代码中,我希望LocalisedString使用我目前在我的视图中用于静态文本绑定的转换器 -
public string MyText // used in the binding in the View
{
get
{
string exclamation;
if (MyValue <= 3.3)
{
exclamation = LocalisedString("Rubbish!");
}
else if (OverallScore > 3.3 && OverallScore <= 6.6)
{
exclamation = LocalisedString("Good!");
}
else
{
exclamation = LocalisedString("Excellent!");
}
return exclamation;
}
}
Run Code Online (Sandbox Code Playgroud)
目前正在使用MvvmCross的第1版.
任何帮助非常感谢.
localization xamarin.ios xamarin.android mvvmcross windows-phone-8
我正试图设置这样的属性 -
-接口:
@property (readwrite, assign) CGColorRef otherBallColor;
Run Code Online (Sandbox Code Playgroud)
-someMethod:
CGColorRef ballColor = [UIColor colorWithRed:255.0/256.0 green:165.0/256.0 blue:239.0/256.0 alpha:1.0].CGColor;
[self setOtherBallColor:ballColor];
Run Code Online (Sandbox Code Playgroud)
一旦我尝试访问它崩溃的价值 -
-someOtherMethod(本例中为drawRect):
CGContextSetFillColorWithColor(context, otherBallColor);
Run Code Online (Sandbox Code Playgroud)
但如果在"someMethod"我做 -
CGColorRef ballColor = [UIColor blueColor].CGColor;
Run Code Online (Sandbox Code Playgroud)
......一切正常 谁能解释一下发生了什么?
非常感谢(PS,对Objective-C来说很新,一般不编程)
在iPhone上,在Xcode中,我可以通过使用这样的代码显示一个弹出视图,它覆盖所有内容,包括Tab Bar等.
[[[[UIApplication sharedApplication] delegate] window] addSubview:mySpecialView];
Run Code Online (Sandbox Code Playgroud)
我试图在MonoTouch中做同样的事情,而我正在使用的代码就是这个 -
UIApplication.SharedApplication.Delegate.Window.AddSubview(mySpecialView);
Run Code Online (Sandbox Code Playgroud)
......但是这个崩溃了.有谁知道我做错了什么?
谢谢你的帮助.
我正在尝试编写一些linq来搜索存储项中的值与列表中的任何值匹配的项目 - 如果它是字符串列表并搜索字符串,我可以轻松地执行此操作,但是当它是列表时enums(ints)我无法弄明白.
List<MyEnum> categories = new List<MyEnum>();
categories.Add(MyEnum.Fred);
categories.Add(MyEnum.Bill);
categories.Add(MyEnum.Jim);
// MyTable.Category is of type MyEnum
return (from o in Table<MyTable>()
where categories.Any(val => o.Category.Contains(val))
select o).Count();
Run Code Online (Sandbox Code Playgroud)
编辑进一步信息 -
代码是:
public int LocalOffersCount(double distance, List<LocalCategory> categories)
{
try
{
return (from o in Table<LocalOffer>() where categories.Any(val => o.Category.Contains(val)) select o).Count();
}
catch (Exception ex)
{
Log.Error("DatabaseService->LocalOffersCount: " + ex.Message);
return 0;
}
}
Run Code Online (Sandbox Code Playgroud)
MyTable包含各种项目,"Category"项是LocalCategory枚举,从1开始到10.
我得到的编译错误是 -
无法从使用中推断出方法`System.Linq.Enumerable.Contains(此System.Collections.Generic.IEnumerable,TSource)'的类型参数.尝试明确指定类型参数(CS0411)
xamarin.ios ×5
c# ×4
modal-dialog ×2
mvvmcross ×2
objective-c ×2
bad-request ×1
cgcolor ×1
contains ×1
delegates ×1
linq ×1
localization ×1
oauth ×1
popup ×1
properties ×1
simulator ×1
singleton ×1
superclass ×1
swift ×1
swiftui ×1
twitter ×1
warnings ×1