起こる原因と、ボタンとラベルを2つ作ってもエラーが起きない方法を知りたいです。
公式サイトの Hello, Mac – チュートリアル
(https://docs.microsoft.com/ja-jp/xamarin/mac/get-started/hello-mac)
で、同じ方法でボタンとラベルを2つ生成してみたところエラーが起こりました。
一度エラーの起こっているコードの箇所を直したが、ビルドを通した後に修正前のコードに修正されてしまいました。
なぜこのような事が起きるのか理解できないので、解説をお願いします。
このようなエラーが起きないように、どうすればXcodeでボタンなどを複数生成すればいいのでしょうか?
ご教授お願いします。
発生している問題・エラーコード
/Users/xxxxxxx/Desktop/DevelopMacAPP/Hello_Mac/Hello_Mac/ViewController.designer.cs(22,22): Error CS0102: The type 'ViewController' already contains a definition for 'ClickedLabel' (CS0102) (Hello_Mac)
発生している問題・コードの場所
C#
1// WARNING 2// 3// This file has been generated automatically by Visual Studio to store outlets and 4// actions made in the UI designer. If it is removed, they will be lost. 5// Manual changes to this file may not be handled correctly. 6// 7using Foundation; 8using System.CodeDom.Compiler; 9 10namespace Hello_Mac 11{ 12 [Register ("ViewController")] 13 partial class ViewController 14 { 15 [Outlet] 16 AppKit.NSButton ClickedLabel { get; set; } 17 18 [Outlet] 19 AppKit.NSTextField ClickLabel { get; set; } 20 21 [Action ("ClickButton:")] 22 partial void ClickButton (Foundation.NSObject sender); 23 24 [Action ("ClickedLabel:")] 25 partial void ClickedLabel (Foundation.NSObject sender); 26 27 void ReleaseDesignerOutlets () 28 { 29 // ここでエラー 30 if (ClickedLabel != null) { 31 ClickedLabel.Dispose (); 32 ClickedLabel = null; 33 } 34 35 if (ClickLabel != null) { 36 ClickLabel.Dispose (); 37 ClickLabel = null; 38 } 39 } 40 } 41} 42
ViewController.h のソースコード
Xcode
1// WARNING 2// This file has been generated automatically by Visual Studio to 3// mirror C# types. Changes in this file made by drag-connecting 4// from the UI designer will be synchronized back to C#, but 5// more complex manual changes may not transfer correctly. 6 7 8#import <Foundation/Foundation.h> 9#import <AppKit/AppKit.h> 10 11 12@interface ViewController : NSViewController { 13 NSButton *_ClickedLabel; 14 NSTextField *_ClickLabel; 15} 16 17@property (nonatomic, retain) IBOutlet NSButton *ClickedLabel; 18 19@property (nonatomic, retain) IBOutlet NSTextField *ClickLabel; 20 21- (IBAction)ClickButton:(id)sender; 22 23- (IBAction)ClickedLabel:(id)sender; 24 25@end
回答1件
あなたの回答
tips
プレビュー