我正在为iphone制作一个基于导航的应用程序.
我的一个视图控制器看起来像这样:
@interface NewComputerViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
Run Code Online (Sandbox Code Playgroud)
所以我用a UITableView
来显示数据.
当视图加载时,我使用顶部导航栏中的一个按钮来运行一个函数loadStuff
加载一些字典中的东西.
我的问题:如何从该loadStuff
函数(属于视图控制器)重新填充该视图控制器中的表视图
class Company
has_and_belongs_to_many :users
end
class User
has_and_belongs_to_many :companies
end
Run Code Online (Sandbox Code Playgroud)
当我删除一家公司时,删除该公司用户的关联的最佳(推荐)方法是什么?(我的意思不是实际用户,只有关联)
在C#表单中,我有一个面板固定在所有侧面,并在内部,一个文本框,锚定顶部/左/右.
当文本加载到文本框中时,我希望它自动垂直展开,这样我就不需要滚动文本框(如果有更多文本不适合面板,最多滚动面板).有没有办法用文本框这样做?(我不限制使用此控件,所以如果有另一个符合描述的控件,请随意提及)
假设我们有这些模型
class Message
belongs_to :messageable, polymorphic: true
end
class Ticket
has_many :messages, as: :messageable
has_many :comments
end
class User
has_many :messages, as: :messageable
has_many :ratings
end
class Rating
belongs_to :user
end
class Comment
belongs_to :ticket
end
Run Code Online (Sandbox Code Playgroud)
现在我想加载所有消息(具有关联的tickets
或者users
),并根据类的类型加载eager,comments
for for tickets
和ratings
forusers
当然Message.includes(:messageable).order("created_at desc")
只会包含直接关联的对象,但问题是如何包含从每个模型类型派生的不同关联类型(即在此示例中,如何预先加载comments for tickets
和ratings for users
)?
这只是一个简单的例子,但是更复杂的情况呢,我想为user
另一个关联包含其他内容,以及如果该关联需要更多包括什么?
activerecord ruby-on-rails polymorphic-associations eager-loading ruby-on-rails-3
我正在尝试将二进制文件(例如可执行文件)读入字符串,然后将其写回
FileStream fs = new FileStream("C:\\tvin.exe", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] bin = br.ReadBytes(Convert.ToInt32(fs.Length));
System.Text.Encoding enc = System.Text.Encoding.ASCII;
string myString = enc.GetString(bin);
fs.Close();
br.Close();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] rebin = encoding.GetBytes(myString);
FileStream fs2 = new FileStream("C:\\tvout.exe", FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs2);
bw.Write(rebin);
fs2.Close();
bw.Close();
Run Code Online (Sandbox Code Playgroud)
这不起作用(结果具有完全相同的字节大小但无法运行)
如果我做bw.Write(bin)结果没问题,但我必须将它保存为字符串
在我的VSTO outlook插件中,我正在尝试放置一个按钮,当我右键单击文件夹时会显示该按钮.在我的启动功能中我有这个:
Outlook.Application myApp = new Outlook.ApplicationClass();
myApp.FolderContextMenuDisplay += new ApplicationEvents_11_FolderContextMenuDisplayEventHandler(myApp_FolderContextMenuDisplay);
Run Code Online (Sandbox Code Playgroud)
然后我有那个处理程序...
void myApp_FolderContextMenuDisplay(CommandBar commandBar, MAPIFolder Folder)
{
var contextButton = commandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true) as CommandBarButton;
contextButton.Visible = true;
contextButton.Caption = "some caption...";
contextButton.Click += new _CommandBarButtonEvents_ClickEventHandler(contextButton_Click);
}
Run Code Online (Sandbox Code Playgroud)
最后点击的处理程序....
void contextButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)
{
//stuff here
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我怎么发送MAPIFolder Folder
从myApp_FolderContextMenuDisplay
到contextButton_Click
?
(如果这可以通过另一种方式完成,我也可以提出建议)
我有一个dll,用mingw构建其中
一个头文件包含:
extern "C" {
int get_mac_address(char * mac); //the function returns a mac address in the char * mac
}
Run Code Online (Sandbox Code Playgroud)
我在另一个使用Visual C++(2008SP1)构建的c ++应用程序中使用此dll,不是托管的,而是普通的c ++(只需包含标题,并调用函数)
但现在我必须在C#应用程序中使用它
问题是我无法弄清楚究竟是什么(我是.net编程的新手)
这就是我尝试过的
public class Hwdinfo {
[DllImport("mydll.dll")]
public static extern void get_mac_address(string s);
}
Run Code Online (Sandbox Code Playgroud)
当我调用该函数时,没有任何反应
(mydll.dll文件位于c#app的bin文件夹中,它不会给我任何错误或警告)
在表格(F1)上我有一个按钮,如果我创建另一个表单(让我们称之为F2)并显示它没有问题
但是我想做这样的事情
我的应用程序中的某些线程正在运行连接并侦听来自服务器的消息.当消息到达时,我的主表单被注册以获得运行函数的事件.从该函数我正在尝试创建并显示F2类型表单(空,没有修改):它显示它然后它冻结我的应用程序.
更确切地说:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ConnectionManagerThread.getResponseListener().MessageReceived += Form1_OnMessageReceived;
}
private void Form1_OnMessageReceived(object sender, MessageEventArgs e) {
Form2 f2 = new Form2();
f2.Show();
}
}
Run Code Online (Sandbox Code Playgroud) 在我的rails3应用程序中,我正在使用设计进行身份验证
现在我正在尝试做i18n.为此,我看到了一个devise.en.yml
在config/locales
,并认为所有我要做的就是让一个devise.ro.yml
它在我的其他语言的翻译.但如果devise.ro.yml
它存在,无论我使用哪种语言,一切都在ro中
为了改变语言,我在我的网址中使用了一个语言环境参数.为此,我在应用程序控制器中设置如下:
before_filter :set_locale
def set_locale
I18n.locale=params[:locale]
end
def default_url_options(options={})
{ :locale => I18n.locale }
end
Run Code Online (Sandbox Code Playgroud)
除了设计部分,我的应用程序中的所有内容都已翻译好
我在这里错过了什么吗?
c# ×6
outlook ×2
.net ×1
activerecord ×1
binaryfiles ×1
c ×1
devise ×1
dll ×1
dllimport ×1
eml ×1
events ×1
iphone ×1
objective-c ×1
resize ×1
string ×1
textbox ×1
uitableview ×1
unmanaged ×1
winforms ×1